@unisat/wallet-state 1.0.4 → 1.1.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.
Files changed (99) hide show
  1. package/LICENSE +0 -5
  2. package/lib/index.d.mts +2012 -200
  3. package/lib/index.d.ts +2012 -200
  4. package/lib/index.js +6951 -570
  5. package/lib/index.js.map +1 -1
  6. package/lib/index.mjs +6754 -517
  7. package/lib/index.mjs.map +1 -1
  8. package/lib/types/index.d.mts +1 -1
  9. package/lib/types/index.d.ts +1 -1
  10. package/package.json +19 -15
  11. package/src/.DS_Store +0 -0
  12. package/src/context/ApprovalContext.tsx +27 -0
  13. package/src/context/DeviceContext.tsx +36 -0
  14. package/src/context/I18nContext.tsx +14 -172
  15. package/src/context/NavigationContext.tsx +305 -0
  16. package/src/context/PriceContext.tsx +2 -2
  17. package/src/context/StorageContext.tsx +393 -0
  18. package/src/context/ToolsContext.tsx +50 -0
  19. package/src/context/WalletContext.tsx +119 -108
  20. package/src/context/index.ts +17 -2
  21. package/src/hooks/accounts.ts +11 -5
  22. package/src/hooks/browser.ts +11 -0
  23. package/src/hooks/global.ts +170 -7
  24. package/src/hooks/index.ts +1 -2
  25. package/src/hooks/settings.ts +28 -37
  26. package/src/hooks/transactions.ts +28 -155
  27. package/src/hooks/ui.ts +232 -36
  28. package/src/index.ts +33 -24
  29. package/src/reducers/accounts.ts +19 -2
  30. package/src/reducers/browser.ts +223 -0
  31. package/src/reducers/global.ts +67 -1
  32. package/src/reducers/index.ts +1 -0
  33. package/src/reducers/transactions.ts +0 -9
  34. package/src/reducers/ui.ts +127 -8
  35. package/src/types/index.ts +1 -1
  36. package/src/ui-hooks/index.ts +107 -0
  37. package/src/ui-hooks/useActionOverviewSectionLogic.ts +150 -0
  38. package/src/ui-hooks/useAddressTypeScreenLogic.ts +160 -0
  39. package/src/ui-hooks/useAlkanesBalanceCardLogic.ts +41 -0
  40. package/src/ui-hooks/useAlkanesCollectionListLogic.ts +68 -0
  41. package/src/ui-hooks/useAlkanesListLogic.ts +69 -0
  42. package/src/ui-hooks/useAlkanesNFTListLogic.ts +42 -0
  43. package/src/ui-hooks/useAlkanesNFTScreenLogic.ts +45 -0
  44. package/src/ui-hooks/useAlkanesTokenScreenLogic.ts +130 -0
  45. package/src/ui-hooks/useAmountInputLogic.ts +80 -0
  46. package/src/ui-hooks/useAnnouncementCardLogic.ts +91 -0
  47. package/src/ui-hooks/useBRC20BalanceCardLogic.ts +115 -0
  48. package/src/ui-hooks/useBRC20InscribeTransferLogic.ts +398 -0
  49. package/src/ui-hooks/useBRC20ListLogic.ts +75 -0
  50. package/src/ui-hooks/useBRC20ProgListLogic.ts +77 -0
  51. package/src/ui-hooks/useBRC20SendScreenLogic.ts +411 -0
  52. package/src/ui-hooks/useBRC20SingleStepScreenLogic.ts +208 -0
  53. package/src/ui-hooks/useBRC20TokenScreenLogic.ts +469 -0
  54. package/src/ui-hooks/useBalanceCardLogic.ts +164 -0
  55. package/src/ui-hooks/useBtcDisplayLogic.ts +16 -0
  56. package/src/ui-hooks/useCAT20BalanceCardLogic.ts +35 -0
  57. package/src/ui-hooks/useCAT20ListLogic.ts +83 -0
  58. package/src/ui-hooks/useCAT20TokenScreenLogic.ts +122 -0
  59. package/src/ui-hooks/useCAT721ListLogic.ts +68 -0
  60. package/src/ui-hooks/useCAT721NFTScreenLogic.ts +37 -0
  61. package/src/ui-hooks/useCreatePasswordScreenLogic.ts +92 -0
  62. package/src/ui-hooks/useCreateWalletLogicImportWordsStep.ts +299 -0
  63. package/src/ui-hooks/useEditAccountNameScreenLogic.ts +71 -0
  64. package/src/ui-hooks/useEditContactScreenLogic.ts +162 -0
  65. package/src/ui-hooks/useEditWalletNameScreenLogic.ts +58 -0
  66. package/src/ui-hooks/useExportMnemonicsScreenLogic.ts +75 -0
  67. package/src/ui-hooks/useExportPrivateKeyScreenLogic.ts +64 -0
  68. package/src/ui-hooks/useFeeRateBarLogic.ts +303 -0
  69. package/src/ui-hooks/useInfiniteList.ts +85 -0
  70. package/src/ui-hooks/useInscriptionListLogic.ts +68 -0
  71. package/src/ui-hooks/useLockTimePageLogic.ts +43 -0
  72. package/src/ui-hooks/useNotificationsLogic.ts +115 -0
  73. package/src/ui-hooks/useOrdinalsInscriptionScreenLogic.ts +130 -0
  74. package/src/ui-hooks/useRunesBalanceCardLogic.ts +44 -0
  75. package/src/ui-hooks/useRunesListLogic.ts +74 -0
  76. package/src/ui-hooks/useRunesTokenScreenLogic.ts +149 -0
  77. package/src/ui-hooks/useSecurityCardLogic.ts +0 -0
  78. package/src/ui-hooks/useSendAlkanesNFTScreenLogic.ts +138 -0
  79. package/src/ui-hooks/useSendAlkanesScreenLogic.ts +192 -0
  80. package/src/ui-hooks/useSendCAT20ScreenLogic.ts +297 -0
  81. package/src/ui-hooks/useSendCAT721ScreenLogic.ts +205 -0
  82. package/src/ui-hooks/useSendOrdinalsInscriptionScreenLogic.ts +137 -0
  83. package/src/ui-hooks/useSendRunesScreenLogic.ts +172 -0
  84. package/src/ui-hooks/useSettingsTabScreenLogic.ts +211 -0
  85. package/src/ui-hooks/useSignMessageLogic.ts +302 -0
  86. package/src/ui-hooks/useSignPsbtLogic.ts +517 -0
  87. package/src/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.ts +95 -0
  88. package/src/ui-hooks/useTxConfirmScreenLogic.ts +47 -0
  89. package/src/ui-hooks/useTxCreateScreenLogic.ts +161 -0
  90. package/src/ui-hooks/useTxFailScreenLogic.ts +26 -0
  91. package/src/ui-hooks/useTxSuccessScreenLogic.ts +33 -0
  92. package/src/updater/accounts.ts +11 -11
  93. package/src/utils/bitcoin-utils.ts +17 -8
  94. package/src/utils/eventBus.ts +2 -1
  95. package/src/utils/password-utils.ts +78 -0
  96. package/src/utils/ui-utils.ts +28 -0
  97. package/src/hooks/approval.ts +0 -72
  98. package/src/hooks/i18n.ts +0 -53
  99. 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,149 @@
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
+ useTxExplorerUrl,
14
+ } from 'src/hooks'
15
+
16
+ export function useRunesTokenScreenLogic() {
17
+ const nav = useNavigation()
18
+ const { runeid } = nav.getRouteState<'RunesTokenScreen'>()
19
+ const [tokenSummary, setTokenSummary] = useState<AddressRunesTokenSummary>({
20
+ runeBalance: {
21
+ runeid: '',
22
+ rune: '',
23
+ spacedRune: '',
24
+ amount: '',
25
+ symbol: '',
26
+ divisibility: 0,
27
+ },
28
+ runeInfo: {
29
+ rune: '',
30
+ runeid: '',
31
+ spacedRune: '',
32
+ symbol: '',
33
+ premine: '',
34
+ mints: '',
35
+ divisibility: 0,
36
+ etching: '',
37
+ terms: {
38
+ amount: '',
39
+ cap: '',
40
+ heightStart: 0,
41
+ heightEnd: 0,
42
+ offsetStart: 0,
43
+ offsetEnd: 0,
44
+ },
45
+ number: 0,
46
+ height: 0,
47
+ txidx: 0,
48
+ timestamp: 0,
49
+ burned: '',
50
+ holders: 0,
51
+ transactions: 0,
52
+ mintable: false,
53
+ remaining: '',
54
+ start: 0,
55
+ end: 0,
56
+ supply: '0',
57
+ parent: '',
58
+ },
59
+ })
60
+
61
+ const wallet = useWallet()
62
+
63
+ const account = useCurrentAccount()
64
+
65
+ const [loading, setLoading] = useState(true)
66
+
67
+ const { t } = useI18n()
68
+
69
+ useEffect(() => {
70
+ wallet.getAddressRunesTokenSummary(account.address, runeid).then(tokenSummary => {
71
+ setTokenSummary(tokenSummary)
72
+ setLoading(false)
73
+ })
74
+ }, [])
75
+
76
+ const enableMint = tokenSummary.runeInfo.mintable
77
+
78
+ const enableTransfer = useMemo(() => {
79
+ let enable = false
80
+ if (tokenSummary.runeBalance.amount !== '0') {
81
+ enable = true
82
+ }
83
+ return enable
84
+ }, [tokenSummary])
85
+
86
+ const tools = useTools()
87
+
88
+ const ordinalsWebsite = useOrdinalsWebsite()
89
+
90
+ const resetTxState = useResetTxState()
91
+
92
+ const txExplorerUrl = useTxExplorerUrl(tokenSummary.runeInfo.etching)
93
+
94
+ const chainType = useChainType()
95
+ const enableTrade = useMemo(() => {
96
+ if (
97
+ chainType === ChainType.BITCOIN_MAINNET ||
98
+ chainType === ChainType.FRACTAL_BITCOIN_MAINNET
99
+ ) {
100
+ return true
101
+ } else {
102
+ return false
103
+ }
104
+ }, [chainType])
105
+
106
+ const iconInfo = useRunesIconInfo(tokenSummary.runeInfo.spacedRune)
107
+ const inscribeUrl = useRunesInscribeUrl(tokenSummary.runeInfo.rune)
108
+ const marketPlaceUrl = useRunesMarketUrl(tokenSummary.runeInfo.spacedRune)
109
+
110
+ const onClickMint = () => {
111
+ nav.navToUrl(inscribeUrl)
112
+ }
113
+
114
+ const onClickSend = () => {
115
+ resetTxState()
116
+ nav.navigate('SendRunesScreen', {
117
+ runeBalance: tokenSummary.runeBalance,
118
+ runeInfo: tokenSummary.runeInfo,
119
+ })
120
+ }
121
+
122
+ const onClickTrade = () => {
123
+ if (marketPlaceUrl) {
124
+ nav.navToUrl(marketPlaceUrl)
125
+ }
126
+ }
127
+
128
+ return {
129
+ runeid,
130
+ tokenSummary,
131
+ iconInfo,
132
+
133
+ loading,
134
+ t,
135
+
136
+ enableMint,
137
+ onClickMint,
138
+
139
+ tools,
140
+ ordinalsWebsite,
141
+ txExplorerUrl,
142
+
143
+ enableTransfer,
144
+ onClickSend,
145
+
146
+ enableTrade,
147
+ onClickTrade,
148
+ }
149
+ }
File without changes
@@ -0,0 +1,138 @@
1
+ import { Inscription, SignedData, SignPsbtParams, ToSignData } from '@unisat/wallet-shared'
2
+ import { useEffect, useRef, useState } from 'react'
3
+ import { useI18n, useNavigation, useTools } 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
+
37
+ const currentAccount = useCurrentAccount()
38
+
39
+ const tools = useTools()
40
+
41
+ const { feeRate } = useFeeRateBar()
42
+
43
+ useEffect(() => {
44
+ setError('')
45
+ setDisabled(true)
46
+
47
+ if (!isValidAddress(toInfo.address)) {
48
+ return
49
+ }
50
+
51
+ if (feeRate <= 0) {
52
+ return
53
+ }
54
+
55
+ setDisabled(false)
56
+ }, [toInfo, feeRate])
57
+
58
+ const transferData = useRef<{
59
+ id: string
60
+ toSignData: ToSignData
61
+ }>({
62
+ id: '',
63
+ toSignData: null,
64
+ })
65
+
66
+ const [step, setStep] = useState(0)
67
+
68
+ const prepareSendAlkanes = usePrepareSendAlkanesCallback()
69
+ const pushBitcoinTx = usePushBitcoinTxCallback()
70
+
71
+ const onCreateTxHandleConfirm = async () => {
72
+ tools.showLoading(true)
73
+ try {
74
+ const toSignData = await prepareSendAlkanes(toInfo, alkanesInfo.alkaneid, '1', feeRate, 'nft')
75
+ if (toSignData) {
76
+ transferData.current.toSignData = toSignData
77
+ setStep(1)
78
+ }
79
+ } catch (e) {
80
+ const msg = (e as any).message
81
+ setError((e as any).message)
82
+ } finally {
83
+ tools.showLoading(false)
84
+ }
85
+ }
86
+
87
+ const onCreateTxHandleBack = () => {
88
+ nav.goBack()
89
+ }
90
+
91
+ const onSignPsbtHandleConfirm = async (signedDatas: SignedData[]) => {
92
+ tools.showLoading(true)
93
+ try {
94
+ const { success, txid, error } = await pushBitcoinTx(signedDatas[0].psbtHex)
95
+ if (success) {
96
+ nav.navigate('TxSuccessScreen', { txid })
97
+ } else {
98
+ throw new Error(error)
99
+ }
100
+ } catch (e) {
101
+ nav.navigate('TxFailScreen', { error: (e as any).message })
102
+ } finally {
103
+ tools.showLoading(false)
104
+ }
105
+ }
106
+
107
+ const onSignPsbtHandleCancel = () => {
108
+ setStep(SendAlkanesNFTScreenStep.CREATE_TX)
109
+ }
110
+
111
+ const onSignPsbtHandleBack = () => {
112
+ setStep(SendAlkanesNFTScreenStep.CREATE_TX)
113
+ }
114
+
115
+ const signPsbtParams: SignPsbtParams = {
116
+ data: {
117
+ toSignDatas: [transferData.current.toSignData],
118
+ },
119
+ }
120
+
121
+ return {
122
+ step,
123
+ t,
124
+ alkanesInfo,
125
+ toInfo,
126
+ disabled,
127
+ error,
128
+ setToInfo,
129
+
130
+ onCreateTxHandleConfirm,
131
+ onCreateTxHandleBack,
132
+
133
+ onSignPsbtHandleConfirm,
134
+ onSignPsbtHandleCancel,
135
+ onSignPsbtHandleBack,
136
+ signPsbtParams,
137
+ }
138
+ }