@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,152 @@
|
|
|
1
|
+
import { Inscription } from '@unisat/wallet-shared'
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
useFeeRateBar,
|
|
5
|
+
useFetchUtxosCallback,
|
|
6
|
+
useI18n,
|
|
7
|
+
useNavigation,
|
|
8
|
+
useOrdinalsTx,
|
|
9
|
+
usePrepareSendOrdinalsInscriptionCallback,
|
|
10
|
+
useTools,
|
|
11
|
+
useWallet,
|
|
12
|
+
} from '..'
|
|
13
|
+
import { getAddressUtxoDust, isValidAddress } from '../utils/bitcoin-utils'
|
|
14
|
+
|
|
15
|
+
export function useSendOrdinalsInscriptionScreenLogic() {
|
|
16
|
+
const [disabled, setDisabled] = useState(true)
|
|
17
|
+
const nav = useNavigation()
|
|
18
|
+
|
|
19
|
+
const { inscription } = nav.getRouteState<'SendOrdinalsInscriptionScreen'>()
|
|
20
|
+
const ordinalsTx = useOrdinalsTx()
|
|
21
|
+
const [toInfo, setToInfo] = useState({
|
|
22
|
+
address: ordinalsTx.toAddress,
|
|
23
|
+
domain: ordinalsTx.toDomain,
|
|
24
|
+
})
|
|
25
|
+
const { t } = useI18n()
|
|
26
|
+
|
|
27
|
+
const fetchBtcUtxos = useFetchUtxosCallback()
|
|
28
|
+
const tools = useTools()
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
tools.showLoading(true)
|
|
31
|
+
fetchBtcUtxos().finally(() => {
|
|
32
|
+
tools.showLoading(false)
|
|
33
|
+
})
|
|
34
|
+
}, [])
|
|
35
|
+
|
|
36
|
+
const [error, setError] = useState('')
|
|
37
|
+
const prepareSendOrdinalsInscription = usePrepareSendOrdinalsInscriptionCallback()
|
|
38
|
+
const { feeRate } = useFeeRateBar()
|
|
39
|
+
const defaultOutputValue = inscription ? inscription.outputValue : 10000
|
|
40
|
+
|
|
41
|
+
const [outputValue, setOutputValue] = useState(defaultOutputValue)
|
|
42
|
+
const [enableRBF, setEnableRBF] = useState(true)
|
|
43
|
+
const [inscriptions, setInscriptions] = useState<Inscription[]>([])
|
|
44
|
+
|
|
45
|
+
const wallet = useWallet()
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
wallet.getEnableRBF().then(enableRBF => {
|
|
48
|
+
setEnableRBF(enableRBF)
|
|
49
|
+
})
|
|
50
|
+
}, [wallet])
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
wallet.getInscriptionUtxoDetail(inscription.inscriptionId).then(v => {
|
|
54
|
+
setInscriptions(v.inscriptions)
|
|
55
|
+
})
|
|
56
|
+
}, [])
|
|
57
|
+
|
|
58
|
+
const onEnableRBFChange = (value: boolean) => {
|
|
59
|
+
setEnableRBF(value)
|
|
60
|
+
wallet.setEnableRBF(value)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const minOutputValue = useMemo(() => {
|
|
64
|
+
if (toInfo.address) {
|
|
65
|
+
return getAddressUtxoDust(toInfo.address)
|
|
66
|
+
} else {
|
|
67
|
+
return 0
|
|
68
|
+
}
|
|
69
|
+
}, [toInfo.address])
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
setDisabled(true)
|
|
73
|
+
setError('')
|
|
74
|
+
|
|
75
|
+
if (feeRate <= 0) {
|
|
76
|
+
setError(t('invalid_fee_rate'))
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let dustUtxo = inscription.outputValue
|
|
81
|
+
try {
|
|
82
|
+
if (toInfo.address) {
|
|
83
|
+
dustUtxo = getAddressUtxoDust(toInfo.address)
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
// console.log(e);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const maxOffset = inscriptions.reduce((pre, cur) => {
|
|
90
|
+
return Math.max(pre, cur.offset)
|
|
91
|
+
}, 0)
|
|
92
|
+
|
|
93
|
+
const minOutputValue = Math.max(maxOffset + 1, dustUtxo)
|
|
94
|
+
|
|
95
|
+
if (outputValue < minOutputValue) {
|
|
96
|
+
setError(`${t('output_value_must_be_at_least')} ${minOutputValue}`)
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!outputValue) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!isValidAddress(toInfo.address)) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setDisabled(false)
|
|
109
|
+
}, [toInfo, feeRate, outputValue, inscriptions])
|
|
110
|
+
|
|
111
|
+
const onAddressInputChange = val => {
|
|
112
|
+
setToInfo(val)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const onClickBack = () => {
|
|
116
|
+
nav.goBack()
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const onClickNext = () => {
|
|
120
|
+
prepareSendOrdinalsInscription({
|
|
121
|
+
toAddressInfo: toInfo,
|
|
122
|
+
inscriptionId: inscription.inscriptionId,
|
|
123
|
+
feeRate,
|
|
124
|
+
outputValue,
|
|
125
|
+
enableRBF,
|
|
126
|
+
})
|
|
127
|
+
.then(toSignData => {
|
|
128
|
+
nav.navigate('TxConfirmScreen', { toSignData })
|
|
129
|
+
})
|
|
130
|
+
.catch(e => {
|
|
131
|
+
console.log(e)
|
|
132
|
+
setError(e.message)
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
t,
|
|
138
|
+
onAddressInputChange,
|
|
139
|
+
toInfo,
|
|
140
|
+
outputValue,
|
|
141
|
+
enableRBF,
|
|
142
|
+
setEnableRBF: onEnableRBFChange,
|
|
143
|
+
minOutputValue,
|
|
144
|
+
defaultOutputValue,
|
|
145
|
+
setOutputValue,
|
|
146
|
+
inscriptions,
|
|
147
|
+
disabled,
|
|
148
|
+
error,
|
|
149
|
+
onClickBack,
|
|
150
|
+
onClickNext,
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { bnUtils } from '@unisat/base-utils'
|
|
2
|
+
import { Inscription } from '@unisat/wallet-shared'
|
|
3
|
+
import BigNumber from 'bignumber.js'
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
5
|
+
import { useI18n, useNavigation, useTools, useWallet } from 'src/context'
|
|
6
|
+
import {
|
|
7
|
+
useCurrentAccount,
|
|
8
|
+
useFeeRateBar,
|
|
9
|
+
useFetchAssetUtxosRunesCallback,
|
|
10
|
+
useFetchUtxosCallback,
|
|
11
|
+
usePrepareSendRunesCallback,
|
|
12
|
+
useRunesTx,
|
|
13
|
+
} from 'src/hooks'
|
|
14
|
+
import { getAddressUtxoDust, isValidAddress } from 'src/utils/bitcoin-utils'
|
|
15
|
+
|
|
16
|
+
export function useSendRunesScreenLogic() {
|
|
17
|
+
const nav = useNavigation()
|
|
18
|
+
const props = nav.getRouteState<'SendRunesScreen'>()
|
|
19
|
+
const { t } = useI18n()
|
|
20
|
+
|
|
21
|
+
const runeBalance = props.runeBalance
|
|
22
|
+
|
|
23
|
+
const runeInfo = props.runeInfo
|
|
24
|
+
|
|
25
|
+
const runesTx = useRunesTx()
|
|
26
|
+
const [inputAmount, setInputAmount] = useState('')
|
|
27
|
+
const [disabled, setDisabled] = useState(true)
|
|
28
|
+
const [toInfo, setToInfo] = useState<{
|
|
29
|
+
address: string
|
|
30
|
+
domain: string
|
|
31
|
+
inscription?: Inscription
|
|
32
|
+
}>({
|
|
33
|
+
address: runesTx.toAddress,
|
|
34
|
+
domain: runesTx.toDomain,
|
|
35
|
+
inscription: undefined,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const [availableBalance, setAvailableBalance] = useState('0')
|
|
39
|
+
const [error, setError] = useState('')
|
|
40
|
+
|
|
41
|
+
const defaultOutputValue = 546
|
|
42
|
+
|
|
43
|
+
const currentAccount = useCurrentAccount()
|
|
44
|
+
const [outputValue, setOutputValue] = useState(defaultOutputValue)
|
|
45
|
+
const [enableRBF, setEnableRBF] = useState(true)
|
|
46
|
+
const minOutputValue = useMemo(() => {
|
|
47
|
+
if (toInfo.address) {
|
|
48
|
+
const dust1 = getAddressUtxoDust(currentAccount.address)
|
|
49
|
+
const dust2 = getAddressUtxoDust(toInfo.address)
|
|
50
|
+
return Math.max(dust1, dust2)
|
|
51
|
+
} else {
|
|
52
|
+
return 0
|
|
53
|
+
}
|
|
54
|
+
}, [toInfo.address, currentAccount.address])
|
|
55
|
+
|
|
56
|
+
const fetchUtxos = useFetchUtxosCallback()
|
|
57
|
+
const wallet = useWallet()
|
|
58
|
+
|
|
59
|
+
const fetchAssetUtxosRunes = useFetchAssetUtxosRunesCallback()
|
|
60
|
+
const tools = useTools()
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
fetchUtxos()
|
|
63
|
+
tools.showLoading(true)
|
|
64
|
+
fetchAssetUtxosRunes(runeInfo.runeid)
|
|
65
|
+
.then(utxos => {
|
|
66
|
+
let balance = new BigNumber(0)
|
|
67
|
+
for (let i = 0; i < utxos.length; i++) {
|
|
68
|
+
const utxo = utxos[i]
|
|
69
|
+
if (utxo.runes) {
|
|
70
|
+
utxo.runes.forEach(rune => {
|
|
71
|
+
if (rune.runeid === runeInfo.runeid) {
|
|
72
|
+
balance = balance.plus(new BigNumber(rune.amount))
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
setAvailableBalance(balance.toString())
|
|
78
|
+
})
|
|
79
|
+
.finally(() => {
|
|
80
|
+
tools.showLoading(false)
|
|
81
|
+
})
|
|
82
|
+
}, [])
|
|
83
|
+
|
|
84
|
+
const prepareSendRunes = usePrepareSendRunesCallback()
|
|
85
|
+
|
|
86
|
+
const { feeRate } = useFeeRateBar()
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
wallet.getEnableRBF().then(enableRBF => {
|
|
90
|
+
setEnableRBF(enableRBF)
|
|
91
|
+
})
|
|
92
|
+
}, [wallet])
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
setError('')
|
|
96
|
+
setDisabled(true)
|
|
97
|
+
|
|
98
|
+
if (!isValidAddress(toInfo.address)) {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
if (!inputAmount) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const runeAmount = bnUtils.fromDecimalAmount(inputAmount, runeInfo.divisibility)
|
|
106
|
+
if (feeRate <= 0) {
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (bnUtils.compareAmount(runeAmount, '0') <= 0) {
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (bnUtils.compareAmount(runeAmount, availableBalance) > 0) {
|
|
115
|
+
setError(t('insufficient_balance'))
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (outputValue < minOutputValue) {
|
|
120
|
+
setError(`${t('output_value_must_be_at_least')} ${minOutputValue}`)
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!outputValue) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setDisabled(false)
|
|
129
|
+
}, [toInfo, inputAmount, feeRate, outputValue, minOutputValue, availableBalance])
|
|
130
|
+
|
|
131
|
+
const totalBalanceStr = useMemo(() => {
|
|
132
|
+
return bnUtils.toDecimalAmount(runeBalance.amount, runeBalance.divisibility)
|
|
133
|
+
}, [runeBalance])
|
|
134
|
+
const availableBalanceStr = useMemo(() => {
|
|
135
|
+
return bnUtils.toDecimalAmount(availableBalance, runeBalance?.divisibility)
|
|
136
|
+
}, [availableBalance, runeBalance])
|
|
137
|
+
|
|
138
|
+
const onClickBack = () => {
|
|
139
|
+
nav.goBack()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const onEnableRBFChange = (value: boolean) => {
|
|
143
|
+
setEnableRBF(value)
|
|
144
|
+
wallet.setEnableRBF(value)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const onClickNext = () => {
|
|
148
|
+
const runeAmount = bnUtils.fromDecimalAmount(inputAmount, runeInfo.divisibility)
|
|
149
|
+
prepareSendRunes({
|
|
150
|
+
toAddressInfo: toInfo,
|
|
151
|
+
runeid: runeInfo.runeid,
|
|
152
|
+
runeAmount: runeAmount,
|
|
153
|
+
outputValue: outputValue,
|
|
154
|
+
feeRate,
|
|
155
|
+
enableRBF,
|
|
156
|
+
})
|
|
157
|
+
.then(toSignData => {
|
|
158
|
+
nav.navigate('TxConfirmScreen', { toSignData })
|
|
159
|
+
})
|
|
160
|
+
.catch(e => {
|
|
161
|
+
console.log(e)
|
|
162
|
+
setError(e.message)
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
// info
|
|
168
|
+
runeInfo,
|
|
169
|
+
inputAmount,
|
|
170
|
+
totalBalanceStr,
|
|
171
|
+
availableBalanceStr,
|
|
172
|
+
|
|
173
|
+
setInputAmount,
|
|
174
|
+
disabled,
|
|
175
|
+
toInfo,
|
|
176
|
+
setToInfo,
|
|
177
|
+
error,
|
|
178
|
+
defaultOutputValue,
|
|
179
|
+
minOutputValue,
|
|
180
|
+
setOutputValue,
|
|
181
|
+
enableRBF,
|
|
182
|
+
setEnableRBF: onEnableRBFChange,
|
|
183
|
+
t,
|
|
184
|
+
|
|
185
|
+
// actions
|
|
186
|
+
onClickBack,
|
|
187
|
+
onClickNext,
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { KeyringType } from '@unisat/keyring-service/types'
|
|
2
|
+
import { ADDRESS_TYPES, FEEDBACK_URL, PlatformEnv } from '@unisat/wallet-shared'
|
|
3
|
+
import { useMemo, useState } from 'react'
|
|
4
|
+
import { useDevice, useI18n, useNavigation, useTools, useWallet } from 'src/context'
|
|
5
|
+
import { useChain, useCurrentAccount, useCurrentKeyring, useVersionInfo } from 'src/hooks'
|
|
6
|
+
|
|
7
|
+
export interface SettingsItemType {
|
|
8
|
+
key: string
|
|
9
|
+
label?: string
|
|
10
|
+
value?: string
|
|
11
|
+
desc?: string
|
|
12
|
+
danger?: boolean
|
|
13
|
+
right: boolean
|
|
14
|
+
icon?: string
|
|
15
|
+
badge?: string
|
|
16
|
+
onClick?: () => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useSettingsTabScreenLogic() {
|
|
20
|
+
const nav = useNavigation()
|
|
21
|
+
const currentKeyring = useCurrentKeyring()
|
|
22
|
+
const currentAccount = useCurrentAccount()
|
|
23
|
+
const chain = useChain()
|
|
24
|
+
const wallet = useWallet()
|
|
25
|
+
const tools = useTools()
|
|
26
|
+
const [connected, setConnected] = useState(false)
|
|
27
|
+
const versionInfo = useVersionInfo()
|
|
28
|
+
const hasUpdate =
|
|
29
|
+
versionInfo.latestVersion && versionInfo.latestVersion !== versionInfo.currentVesion
|
|
30
|
+
const { t } = useI18n()
|
|
31
|
+
|
|
32
|
+
const { isExtensionInExpandView } = useDevice()
|
|
33
|
+
|
|
34
|
+
const isCustomHdPath = useMemo(() => {
|
|
35
|
+
const item = ADDRESS_TYPES[currentKeyring.addressType]
|
|
36
|
+
return currentKeyring.hdPath !== '' && item.hdPath !== currentKeyring.hdPath
|
|
37
|
+
}, [currentKeyring])
|
|
38
|
+
|
|
39
|
+
const settings_connectedSites: SettingsItemType = useMemo(() => {
|
|
40
|
+
const value = connected ? t('connected') : t('not_connected')
|
|
41
|
+
return {
|
|
42
|
+
key: 'settings_connectedSites',
|
|
43
|
+
label: t('connected_sites'),
|
|
44
|
+
value,
|
|
45
|
+
desc: '',
|
|
46
|
+
right: true,
|
|
47
|
+
icon: 'connectedSites',
|
|
48
|
+
onClick: () => {
|
|
49
|
+
nav.navigate('ConnectedSitesScreen')
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
}, [t, connected])
|
|
53
|
+
|
|
54
|
+
const settings_addressBook: SettingsItemType = useMemo(() => {
|
|
55
|
+
return {
|
|
56
|
+
key: 'settings_addressBook',
|
|
57
|
+
label: t('address_book'),
|
|
58
|
+
value: t('addressbook_desc'),
|
|
59
|
+
desc: '',
|
|
60
|
+
right: true,
|
|
61
|
+
icon: 'addressBook',
|
|
62
|
+
onClick: () => {
|
|
63
|
+
// todo
|
|
64
|
+
nav.navigate('ContactsScreen', {})
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
}, [t])
|
|
68
|
+
const settings_addressType: SettingsItemType = useMemo(() => {
|
|
69
|
+
let value = ''
|
|
70
|
+
const item = ADDRESS_TYPES[currentKeyring.addressType]
|
|
71
|
+
const hdPath = currentKeyring.hdPath || item.hdPath
|
|
72
|
+
if (currentKeyring.type === KeyringType.SimpleKeyring) {
|
|
73
|
+
value = `${item.name}`
|
|
74
|
+
} else {
|
|
75
|
+
value = `${item.name} (${hdPath}/${currentAccount.index})`
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
key: 'settings_addressType',
|
|
79
|
+
label: t('address_type'),
|
|
80
|
+
value,
|
|
81
|
+
desc: '',
|
|
82
|
+
right: true,
|
|
83
|
+
icon: 'addressType',
|
|
84
|
+
onClick: () => {
|
|
85
|
+
if (isCustomHdPath) {
|
|
86
|
+
tools.showTip(
|
|
87
|
+
t(
|
|
88
|
+
'the_wallet_currently_uses_a_custom_hd_path_and_does_not_support_switching_address_types'
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
nav.navigate('AddressTypeScreen')
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
}, [t, isCustomHdPath])
|
|
97
|
+
|
|
98
|
+
const settings_advanced = useMemo(() => {
|
|
99
|
+
return {
|
|
100
|
+
key: 'settings_advanced',
|
|
101
|
+
label: t('settings'),
|
|
102
|
+
value: t('advanced_settings'),
|
|
103
|
+
desc: '',
|
|
104
|
+
right: true,
|
|
105
|
+
icon: 'advance',
|
|
106
|
+
onClick: () => {
|
|
107
|
+
nav.navigate('AdvancedScreen')
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
}, [t])
|
|
111
|
+
|
|
112
|
+
const settings_feedback = useMemo(() => {
|
|
113
|
+
return {
|
|
114
|
+
key: 'settings_feedback',
|
|
115
|
+
label: t('feedback'),
|
|
116
|
+
value: t('let_us_know_what_you_think'),
|
|
117
|
+
desc: '',
|
|
118
|
+
route: '',
|
|
119
|
+
right: true,
|
|
120
|
+
icon: 'feedback',
|
|
121
|
+
onClick: () => {
|
|
122
|
+
const addressParam = currentAccount.address
|
|
123
|
+
|
|
124
|
+
let feedbackUrl = FEEDBACK_URL
|
|
125
|
+
feedbackUrl += `?address=${addressParam}&category=wallet`
|
|
126
|
+
|
|
127
|
+
nav.navToUrl(feedbackUrl)
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
}, [t])
|
|
131
|
+
|
|
132
|
+
const settings_rateus = useMemo(() => {
|
|
133
|
+
return {
|
|
134
|
+
key: 'settings_rateus',
|
|
135
|
+
label: t('rate_us'),
|
|
136
|
+
value: t('like_our_wallet_wed_love_your_rating'),
|
|
137
|
+
desc: '',
|
|
138
|
+
route: '',
|
|
139
|
+
right: true,
|
|
140
|
+
icon: 'rateUs',
|
|
141
|
+
onClick: () => {
|
|
142
|
+
nav.navToUrl(PlatformEnv.REVIEW_URL)
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
}, [t])
|
|
146
|
+
|
|
147
|
+
const settings_aboutus = useMemo(() => {
|
|
148
|
+
return {
|
|
149
|
+
key: 'settings_aboutus',
|
|
150
|
+
label: t('about_us'),
|
|
151
|
+
value: '',
|
|
152
|
+
desc: '',
|
|
153
|
+
right: true,
|
|
154
|
+
icon: 'aboutUsLogo',
|
|
155
|
+
badge: hasUpdate ? t('new_version') : undefined,
|
|
156
|
+
onClick: () => {
|
|
157
|
+
nav.navigate('AboutUsScreen')
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
}, [t, hasUpdate])
|
|
161
|
+
|
|
162
|
+
const settings_lockwallet = useMemo(() => {
|
|
163
|
+
return {
|
|
164
|
+
key: 'settings_lockwallet',
|
|
165
|
+
label: '',
|
|
166
|
+
value: '',
|
|
167
|
+
desc: t('lock_immediately'),
|
|
168
|
+
right: false,
|
|
169
|
+
onClick: () => {
|
|
170
|
+
wallet.lockWallet()
|
|
171
|
+
|
|
172
|
+
// Add small delay to ensure lock state updates before navigation
|
|
173
|
+
// Prevents race condition where unlock screen might redirect back to main
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
nav.navToLock({
|
|
176
|
+
autoUnlockByFace: false,
|
|
177
|
+
})
|
|
178
|
+
}, 10)
|
|
179
|
+
return
|
|
180
|
+
},
|
|
181
|
+
}
|
|
182
|
+
}, [t])
|
|
183
|
+
|
|
184
|
+
const settings_expandview = useMemo(() => {
|
|
185
|
+
if (isExtensionInExpandView) {
|
|
186
|
+
return null
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
key: 'settings_expandview',
|
|
190
|
+
label: '',
|
|
191
|
+
value: '',
|
|
192
|
+
desc: t('expand_view'),
|
|
193
|
+
right: false,
|
|
194
|
+
onClick: () => {
|
|
195
|
+
nav.openExtensionInTab()
|
|
196
|
+
},
|
|
197
|
+
}
|
|
198
|
+
}, [t])
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
settings_connectedSites,
|
|
202
|
+
settings_addressBook,
|
|
203
|
+
settings_addressType,
|
|
204
|
+
settings_advanced,
|
|
205
|
+
settings_feedback,
|
|
206
|
+
settings_rateus,
|
|
207
|
+
settings_aboutus,
|
|
208
|
+
settings_lockwallet,
|
|
209
|
+
settings_expandview,
|
|
210
|
+
}
|
|
211
|
+
}
|