@unisat/wallet-state 1.2.0 → 1.2.1

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 (210) hide show
  1. package/lib/index.d.mts +9 -1
  2. package/lib/index.d.ts +2827 -31
  3. package/lib/index.js +229 -101
  4. package/lib/index.js.map +1 -1
  5. package/lib/index.mjs +231 -104
  6. package/lib/index.mjs.map +1 -1
  7. package/lib/types/index.d.ts +34 -3
  8. package/package.json +3 -3
  9. package/src/context/NavigationContext.tsx +1 -0
  10. package/src/hooks/accounts.ts +7 -2
  11. package/src/hooks/transactions.ts +52 -8
  12. package/src/hooks/ui.ts +77 -65
  13. package/src/ui-hooks/useAddressTypeScreenLogic.ts +22 -8
  14. package/src/ui-hooks/useAlkanesNFTScreenLogic.ts +3 -2
  15. package/src/ui-hooks/useAlkanesTokenScreenLogic.ts +4 -2
  16. package/src/ui-hooks/useBRC20TokenScreenLogic.ts +4 -1
  17. package/src/ui-hooks/useCAT20TokenScreenLogic.ts +11 -2
  18. package/src/ui-hooks/useCAT721NFTScreenLogic.ts +3 -1
  19. package/src/ui-hooks/useOrdinalsInscriptionScreenLogic.ts +3 -2
  20. package/src/ui-hooks/useRunesTokenScreenLogic.ts +4 -2
  21. package/src/ui-hooks/useSendOrdinalsInscriptionScreenLogic.ts +2 -5
  22. package/src/ui-hooks/useSettingsTabScreenLogic.ts +18 -3
  23. package/src/ui-hooks/useSignMessageLogic.ts +37 -16
  24. package/src/ui-hooks/useSignPsbtLogic.ts +31 -15
  25. package/lib/actions/global.d.ts +0 -2
  26. package/lib/actions/global.d.ts.map +0 -1
  27. package/lib/context/ApprovalContext.d.ts +0 -9
  28. package/lib/context/ApprovalContext.d.ts.map +0 -1
  29. package/lib/context/DeviceContext.d.ts +0 -17
  30. package/lib/context/DeviceContext.d.ts.map +0 -1
  31. package/lib/context/I18nContext.d.ts +0 -13
  32. package/lib/context/I18nContext.d.ts.map +0 -1
  33. package/lib/context/NavigationContext.d.ts +0 -218
  34. package/lib/context/NavigationContext.d.ts.map +0 -1
  35. package/lib/context/PriceContext.d.ts +0 -13
  36. package/lib/context/PriceContext.d.ts.map +0 -1
  37. package/lib/context/StorageContext.d.ts +0 -60
  38. package/lib/context/StorageContext.d.ts.map +0 -1
  39. package/lib/context/ToolsContext.d.ts +0 -17
  40. package/lib/context/ToolsContext.d.ts.map +0 -1
  41. package/lib/context/WalletContext.d.ts +0 -493
  42. package/lib/context/WalletContext.d.ts.map +0 -1
  43. package/lib/context/index.d.ts +0 -9
  44. package/lib/context/index.d.ts.map +0 -1
  45. package/lib/hooks/accounts.d.ts +0 -34
  46. package/lib/hooks/accounts.d.ts.map +0 -1
  47. package/lib/hooks/base.d.ts +0 -14
  48. package/lib/hooks/base.d.ts.map +0 -1
  49. package/lib/hooks/browser.d.ts +0 -32
  50. package/lib/hooks/browser.d.ts.map +0 -1
  51. package/lib/hooks/discovery.d.ts +0 -17
  52. package/lib/hooks/discovery.d.ts.map +0 -1
  53. package/lib/hooks/global.d.ts +0 -43
  54. package/lib/hooks/global.d.ts.map +0 -1
  55. package/lib/hooks/index.d.ts +0 -10
  56. package/lib/hooks/index.d.ts.map +0 -1
  57. package/lib/hooks/keyrings.d.ts +0 -5
  58. package/lib/hooks/keyrings.d.ts.map +0 -1
  59. package/lib/hooks/settings.d.ts +0 -43
  60. package/lib/hooks/settings.d.ts.map +0 -1
  61. package/lib/hooks/transactions.d.ts +0 -67
  62. package/lib/hooks/transactions.d.ts.map +0 -1
  63. package/lib/hooks/ui.d.ts +0 -112
  64. package/lib/hooks/ui.d.ts.map +0 -1
  65. package/lib/index.d.ts.map +0 -1
  66. package/lib/reducers/accounts.d.ts +0 -49
  67. package/lib/reducers/accounts.d.ts.map +0 -1
  68. package/lib/reducers/browser.d.ts +0 -49
  69. package/lib/reducers/browser.d.ts.map +0 -1
  70. package/lib/reducers/discovery.d.ts +0 -22
  71. package/lib/reducers/discovery.d.ts.map +0 -1
  72. package/lib/reducers/global.d.ts +0 -35
  73. package/lib/reducers/global.d.ts.map +0 -1
  74. package/lib/reducers/index.d.ts +0 -9
  75. package/lib/reducers/index.d.ts.map +0 -1
  76. package/lib/reducers/keyrings.d.ts +0 -10
  77. package/lib/reducers/keyrings.d.ts.map +0 -1
  78. package/lib/reducers/settings.d.ts +0 -16
  79. package/lib/reducers/settings.d.ts.map +0 -1
  80. package/lib/reducers/transactions.d.ts +0 -61
  81. package/lib/reducers/transactions.d.ts.map +0 -1
  82. package/lib/reducers/ui.d.ts +0 -55
  83. package/lib/reducers/ui.d.ts.map +0 -1
  84. package/lib/types/index.d.ts.map +0 -1
  85. package/lib/types/ui.d.ts +0 -31
  86. package/lib/types/ui.d.ts.map +0 -1
  87. package/lib/ui-hooks/index.d.ts +0 -55
  88. package/lib/ui-hooks/index.d.ts.map +0 -1
  89. package/lib/ui-hooks/useActionOverviewSectionLogic.d.ts +0 -12
  90. package/lib/ui-hooks/useActionOverviewSectionLogic.d.ts.map +0 -1
  91. package/lib/ui-hooks/useAddressTypeScreenLogic.d.ts +0 -19
  92. package/lib/ui-hooks/useAddressTypeScreenLogic.d.ts.map +0 -1
  93. package/lib/ui-hooks/useAlkanesBalanceCardLogic.d.ts +0 -19
  94. package/lib/ui-hooks/useAlkanesBalanceCardLogic.d.ts.map +0 -1
  95. package/lib/ui-hooks/useAlkanesCollectionListLogic.d.ts +0 -11
  96. package/lib/ui-hooks/useAlkanesCollectionListLogic.d.ts.map +0 -1
  97. package/lib/ui-hooks/useAlkanesListLogic.d.ts +0 -14
  98. package/lib/ui-hooks/useAlkanesListLogic.d.ts.map +0 -1
  99. package/lib/ui-hooks/useAlkanesNFTListLogic.d.ts +0 -11
  100. package/lib/ui-hooks/useAlkanesNFTListLogic.d.ts.map +0 -1
  101. package/lib/ui-hooks/useAlkanesNFTScreenLogic.d.ts +0 -9
  102. package/lib/ui-hooks/useAlkanesNFTScreenLogic.d.ts.map +0 -1
  103. package/lib/ui-hooks/useAlkanesTokenScreenLogic.d.ts +0 -22
  104. package/lib/ui-hooks/useAlkanesTokenScreenLogic.d.ts.map +0 -1
  105. package/lib/ui-hooks/useAmountInputLogic.d.ts +0 -22
  106. package/lib/ui-hooks/useAmountInputLogic.d.ts.map +0 -1
  107. package/lib/ui-hooks/useAnnouncementCardLogic.d.ts +0 -11
  108. package/lib/ui-hooks/useAnnouncementCardLogic.d.ts.map +0 -1
  109. package/lib/ui-hooks/useBRC20BalanceCardLogic.d.ts +0 -26
  110. package/lib/ui-hooks/useBRC20BalanceCardLogic.d.ts.map +0 -1
  111. package/lib/ui-hooks/useBRC20InscribeTransferLogic.d.ts +0 -103
  112. package/lib/ui-hooks/useBRC20InscribeTransferLogic.d.ts.map +0 -1
  113. package/lib/ui-hooks/useBRC20ListLogic.d.ts +0 -14
  114. package/lib/ui-hooks/useBRC20ListLogic.d.ts.map +0 -1
  115. package/lib/ui-hooks/useBRC20ProgListLogic.d.ts +0 -14
  116. package/lib/ui-hooks/useBRC20ProgListLogic.d.ts.map +0 -1
  117. package/lib/ui-hooks/useBRC20SendScreenLogic.d.ts +0 -67
  118. package/lib/ui-hooks/useBRC20SendScreenLogic.d.ts.map +0 -1
  119. package/lib/ui-hooks/useBRC20SingleStepScreenLogic.d.ts +0 -36
  120. package/lib/ui-hooks/useBRC20SingleStepScreenLogic.d.ts.map +0 -1
  121. package/lib/ui-hooks/useBRC20TokenScreenLogic.d.ts +0 -75
  122. package/lib/ui-hooks/useBRC20TokenScreenLogic.d.ts.map +0 -1
  123. package/lib/ui-hooks/useBalanceCardLogic.d.ts +0 -26
  124. package/lib/ui-hooks/useBalanceCardLogic.d.ts.map +0 -1
  125. package/lib/ui-hooks/useBtcDisplayLogic.d.ts +0 -5
  126. package/lib/ui-hooks/useBtcDisplayLogic.d.ts.map +0 -1
  127. package/lib/ui-hooks/useCAT20BalanceCardLogic.d.ts +0 -20
  128. package/lib/ui-hooks/useCAT20BalanceCardLogic.d.ts.map +0 -1
  129. package/lib/ui-hooks/useCAT20ListLogic.d.ts +0 -14
  130. package/lib/ui-hooks/useCAT20ListLogic.d.ts.map +0 -1
  131. package/lib/ui-hooks/useCAT20TokenScreenLogic.d.ts +0 -19
  132. package/lib/ui-hooks/useCAT20TokenScreenLogic.d.ts.map +0 -1
  133. package/lib/ui-hooks/useCAT721ListLogic.d.ts +0 -11
  134. package/lib/ui-hooks/useCAT721ListLogic.d.ts.map +0 -1
  135. package/lib/ui-hooks/useCAT721NFTScreenLogic.d.ts +0 -9
  136. package/lib/ui-hooks/useCAT721NFTScreenLogic.d.ts.map +0 -1
  137. package/lib/ui-hooks/useCreatePasswordScreenLogic.d.ts +0 -27
  138. package/lib/ui-hooks/useCreatePasswordScreenLogic.d.ts.map +0 -1
  139. package/lib/ui-hooks/useCreateWalletLogicImportWordsStep.d.ts +0 -78
  140. package/lib/ui-hooks/useCreateWalletLogicImportWordsStep.d.ts.map +0 -1
  141. package/lib/ui-hooks/useEditAccountNameScreenLogic.d.ts +0 -18
  142. package/lib/ui-hooks/useEditAccountNameScreenLogic.d.ts.map +0 -1
  143. package/lib/ui-hooks/useEditContactScreenLogic.d.ts +0 -24
  144. package/lib/ui-hooks/useEditContactScreenLogic.d.ts.map +0 -1
  145. package/lib/ui-hooks/useEditWalletNameScreenLogic.d.ts +0 -15
  146. package/lib/ui-hooks/useEditWalletNameScreenLogic.d.ts.map +0 -1
  147. package/lib/ui-hooks/useExportMnemonicsScreenLogic.d.ts +0 -18
  148. package/lib/ui-hooks/useExportMnemonicsScreenLogic.d.ts.map +0 -1
  149. package/lib/ui-hooks/useExportPrivateKeyScreenLogic.d.ts +0 -17
  150. package/lib/ui-hooks/useExportPrivateKeyScreenLogic.d.ts.map +0 -1
  151. package/lib/ui-hooks/useFeeRateBarLogic.d.ts +0 -34
  152. package/lib/ui-hooks/useFeeRateBarLogic.d.ts.map +0 -1
  153. package/lib/ui-hooks/useInfiniteList.d.ts +0 -19
  154. package/lib/ui-hooks/useInfiniteList.d.ts.map +0 -1
  155. package/lib/ui-hooks/useInscriptionListLogic.d.ts +0 -11
  156. package/lib/ui-hooks/useInscriptionListLogic.d.ts.map +0 -1
  157. package/lib/ui-hooks/useLockTimePageLogic.d.ts +0 -11
  158. package/lib/ui-hooks/useLockTimePageLogic.d.ts.map +0 -1
  159. package/lib/ui-hooks/useNotificationsLogic.d.ts +0 -14
  160. package/lib/ui-hooks/useNotificationsLogic.d.ts.map +0 -1
  161. package/lib/ui-hooks/useOrdinalsInscriptionScreenLogic.d.ts +0 -27
  162. package/lib/ui-hooks/useOrdinalsInscriptionScreenLogic.d.ts.map +0 -1
  163. package/lib/ui-hooks/useRunesBalanceCardLogic.d.ts +0 -19
  164. package/lib/ui-hooks/useRunesBalanceCardLogic.d.ts.map +0 -1
  165. package/lib/ui-hooks/useRunesListLogic.d.ts +0 -14
  166. package/lib/ui-hooks/useRunesListLogic.d.ts.map +0 -1
  167. package/lib/ui-hooks/useRunesTokenScreenLogic.d.ts +0 -22
  168. package/lib/ui-hooks/useRunesTokenScreenLogic.d.ts.map +0 -1
  169. package/lib/ui-hooks/useSecurityCardLogic.d.ts +0 -1
  170. package/lib/ui-hooks/useSecurityCardLogic.d.ts.map +0 -1
  171. package/lib/ui-hooks/useSendAlkanesNFTScreenLogic.d.ts +0 -32
  172. package/lib/ui-hooks/useSendAlkanesNFTScreenLogic.d.ts.map +0 -1
  173. package/lib/ui-hooks/useSendAlkanesScreenLogic.d.ts +0 -37
  174. package/lib/ui-hooks/useSendAlkanesScreenLogic.d.ts.map +0 -1
  175. package/lib/ui-hooks/useSendCAT20ScreenLogic.d.ts +0 -44
  176. package/lib/ui-hooks/useSendCAT20ScreenLogic.d.ts.map +0 -1
  177. package/lib/ui-hooks/useSendCAT721ScreenLogic.d.ts +0 -40
  178. package/lib/ui-hooks/useSendCAT721ScreenLogic.d.ts.map +0 -1
  179. package/lib/ui-hooks/useSendOrdinalsInscriptionScreenLogic.d.ts +0 -22
  180. package/lib/ui-hooks/useSendOrdinalsInscriptionScreenLogic.d.ts.map +0 -1
  181. package/lib/ui-hooks/useSendRunesScreenLogic.d.ts +0 -30
  182. package/lib/ui-hooks/useSendRunesScreenLogic.d.ts.map +0 -1
  183. package/lib/ui-hooks/useSettingsTabScreenLogic.d.ts +0 -72
  184. package/lib/ui-hooks/useSettingsTabScreenLogic.d.ts.map +0 -1
  185. package/lib/ui-hooks/useSignMessageLogic.d.ts +0 -54
  186. package/lib/ui-hooks/useSignMessageLogic.d.ts.map +0 -1
  187. package/lib/ui-hooks/useSignPsbtLogic.d.ts +0 -82
  188. package/lib/ui-hooks/useSignPsbtLogic.d.ts.map +0 -1
  189. package/lib/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.d.ts +0 -15
  190. package/lib/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.d.ts.map +0 -1
  191. package/lib/ui-hooks/useTxConfirmScreenLogic.d.ts +0 -8
  192. package/lib/ui-hooks/useTxConfirmScreenLogic.d.ts.map +0 -1
  193. package/lib/ui-hooks/useTxCreateScreenLogic.d.ts +0 -28
  194. package/lib/ui-hooks/useTxCreateScreenLogic.d.ts.map +0 -1
  195. package/lib/ui-hooks/useTxFailScreenLogic.d.ts +0 -7
  196. package/lib/ui-hooks/useTxFailScreenLogic.d.ts.map +0 -1
  197. package/lib/ui-hooks/useTxSuccessScreenLogic.d.ts +0 -8
  198. package/lib/ui-hooks/useTxSuccessScreenLogic.d.ts.map +0 -1
  199. package/lib/updater/accounts.d.ts +0 -2
  200. package/lib/updater/accounts.d.ts.map +0 -1
  201. package/lib/updater/index.d.ts +0 -2
  202. package/lib/updater/index.d.ts.map +0 -1
  203. package/lib/utils/bitcoin-utils.d.ts +0 -7
  204. package/lib/utils/bitcoin-utils.d.ts.map +0 -1
  205. package/lib/utils/eventBus.d.ts +0 -12
  206. package/lib/utils/eventBus.d.ts.map +0 -1
  207. package/lib/utils/password-utils.d.ts +0 -12
  208. package/lib/utils/password-utils.d.ts.map +0 -1
  209. package/lib/utils/ui-utils.d.ts +0 -4
  210. package/lib/utils/ui-utils.d.ts.map +0 -1
@@ -1,3 +1,34 @@
1
- export * from './ui';
2
- export type TabOption = 'home' | 'discover' | 'settings' | 'app';
3
- //# sourceMappingURL=index.d.ts.map
1
+ declare enum AssetTabKey {
2
+ ORDINALS = 0,
3
+ ATOMICALS = 1,
4
+ RUNES = 2,
5
+ CAT = 3,
6
+ MORE = 4
7
+ }
8
+ declare enum OrdinalsAssetTabKey {
9
+ ALL = 0,
10
+ BRC20 = 1,
11
+ BRC20_6BYTE = 2
12
+ }
13
+ declare enum CATAssetTabKey {
14
+ CAT20 = 0,
15
+ CAT721 = 1,
16
+ CAT20_V2 = 2,
17
+ CAT721_V2 = 3
18
+ }
19
+ declare enum AlkanesAssetTabKey {
20
+ TOKEN = 0,
21
+ COLLECTION = 1
22
+ }
23
+ declare enum MoreAssetTabKey {
24
+ ALKANES_TOKEN = 0,
25
+ ALKANES_COLLECTION = 1
26
+ }
27
+ declare enum NavigationSource {
28
+ BACK = 0,
29
+ NORMAL = 1
30
+ }
31
+
32
+ type TabOption = 'home' | 'discover' | 'settings' | 'app';
33
+
34
+ export { AlkanesAssetTabKey, AssetTabKey, CATAssetTabKey, MoreAssetTabKey, NavigationSource, OrdinalsAssetTabKey, TabOption };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisat/wallet-state",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Redux state management for UniSat wallet, shared between platforms",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
@@ -29,9 +29,9 @@
29
29
  "react-redux": "8.0.1",
30
30
  "@unisat/babylon-service": "1.1.0",
31
31
  "@unisat/base-utils": "0.2.0",
32
- "@unisat/wallet-shared": "0.3.0",
32
+ "@unisat/wallet-types": "1.1.0",
33
33
  "@unisat/keyring-service": "1.2.0",
34
- "@unisat/wallet-types": "1.1.0"
34
+ "@unisat/wallet-shared": "0.3.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@reduxjs/toolkit": "^1.9.2",
@@ -53,6 +53,7 @@ export type RouteParamList = {
53
53
  }
54
54
  CreateSimpleWalletScreen: undefined
55
55
  CreateWatchWalletScreen: undefined
56
+ CreateReadonlyWalletScreen: undefined
56
57
  CreateColdWalletScreen: {
57
58
  fromUnlock?: boolean
58
59
  }
@@ -1,6 +1,6 @@
1
- import { useCallback } from 'react'
1
+ import { useCallback, useMemo } from 'react'
2
2
 
3
- import { Account } from '@unisat/wallet-shared'
3
+ import { Account, getAccountCapabilities } from '@unisat/wallet-shared'
4
4
 
5
5
  import { KeyringType } from '@unisat/keyring-service/types'
6
6
  import { AddressType, ChainType } from '@unisat/wallet-types'
@@ -27,6 +27,11 @@ export function useCurrentAddress() {
27
27
  return accountsState.current.address
28
28
  }
29
29
 
30
+ export function useCurrentAccountCapabilities() {
31
+ const currentAccount = useCurrentAccount()
32
+ return useMemo(() => getAccountCapabilities(currentAccount), [currentAccount])
33
+ }
34
+
30
35
  export function useAccounts() {
31
36
  const accountsState = useAccountsState()
32
37
  return accountsState.accounts
@@ -5,7 +5,7 @@ import { ToAddressInfo, ToSignData, UnspentOutput } from '@unisat/wallet-shared'
5
5
  import { numUtils, timeUtils } from '@unisat/base-utils'
6
6
  import { AppState, useI18n, useTools } from '..'
7
7
  import { useWallet } from '../context/WalletContext'
8
- import { useAccountAddress, useCurrentAccount } from '../hooks/accounts'
8
+ import { useAccountAddress, useCurrentAccount, useCurrentAccountCapabilities } from '../hooks/accounts'
9
9
  import { accountActions } from '../reducers/accounts'
10
10
  import { transactionsActions } from '../reducers/transactions'
11
11
  import { useAppDispatch, useAppSelector } from './base'
@@ -25,6 +25,7 @@ export function usePrepareSendBTCCallback() {
25
25
  const fromAddress = useAccountAddress()
26
26
  const utxos = useUtxos()
27
27
  const fetchUtxos = useFetchUtxosCallback()
28
+ const accountCapabilities = useCurrentAccountCapabilities()
28
29
 
29
30
  const { t } = useI18n()
30
31
  return useCallback(
@@ -45,6 +46,9 @@ export function usePrepareSendBTCCallback() {
45
46
  disableAutoAdjust?: boolean
46
47
  enableRBF?: boolean
47
48
  }) => {
49
+ if (!accountCapabilities.canCreateSigningRequest) {
50
+ throw new Error(t('not_supported'))
51
+ }
48
52
  let _utxos: UnspentOutput[] = utxos
49
53
  if (_utxos.length === 0) {
50
54
  _utxos = await fetchUtxos()
@@ -83,13 +87,15 @@ export function usePrepareSendBTCCallback() {
83
87
 
84
88
  return res
85
89
  },
86
- [dispatch, wallet, fromAddress, utxos, fetchUtxos]
90
+ [dispatch, wallet, fromAddress, utxos, fetchUtxos, accountCapabilities.canCreateSigningRequest, t]
87
91
  )
88
92
  }
89
93
 
90
94
  export function usePrepareSendBypassHeadOffsetsCallback() {
91
95
  const dispatch = useAppDispatch()
92
96
  const wallet = useWallet()
97
+ const accountCapabilities = useCurrentAccountCapabilities()
98
+ const { t } = useI18n()
93
99
  return useCallback(
94
100
  async ({
95
101
  toAddressInfo,
@@ -102,6 +108,9 @@ export function usePrepareSendBypassHeadOffsetsCallback() {
102
108
  feeRate: number
103
109
  enableRBF?: boolean
104
110
  }) => {
111
+ if (!accountCapabilities.canCreateSigningRequest) {
112
+ throw new Error(t('not_supported'))
113
+ }
105
114
  const res = await wallet.createSendBTCOffsetPsbt(
106
115
  [
107
116
  {
@@ -114,7 +123,7 @@ export function usePrepareSendBypassHeadOffsetsCallback() {
114
123
  )
115
124
  return res
116
125
  },
117
- [dispatch, wallet]
126
+ [dispatch, wallet, accountCapabilities.canCreateSigningRequest, t]
118
127
  )
119
128
  }
120
129
 
@@ -167,6 +176,8 @@ export function usePrepareSendOrdinalsInscriptionCallback() {
167
176
  const fromAddress = useAccountAddress()
168
177
  const utxos = useUtxos()
169
178
  const fetchUtxos = useFetchUtxosCallback()
179
+ const accountCapabilities = useCurrentAccountCapabilities()
180
+ const { t } = useI18n()
170
181
  return useCallback(
171
182
  async ({
172
183
  toAddressInfo,
@@ -181,6 +192,9 @@ export function usePrepareSendOrdinalsInscriptionCallback() {
181
192
  outputValue?: number
182
193
  enableRBF?: boolean
183
194
  }) => {
195
+ if (!accountCapabilities.canCreateSigningRequest) {
196
+ throw new Error(t('not_supported'))
197
+ }
184
198
  if (!feeRate) {
185
199
  const summary = await wallet.getFeeSummary()
186
200
  feeRate = summary.list[1]!.feeRate
@@ -202,7 +216,7 @@ export function usePrepareSendOrdinalsInscriptionCallback() {
202
216
 
203
217
  return toSignData
204
218
  },
205
- [dispatch, wallet, fromAddress, utxos]
219
+ [dispatch, wallet, fromAddress, utxos, accountCapabilities.canCreateSigningRequest, t]
206
220
  )
207
221
  }
208
222
 
@@ -212,6 +226,8 @@ export function usePrepareSendOrdinalsInscriptionsCallback() {
212
226
  const fromAddress = useAccountAddress()
213
227
  const fetchUtxos = useFetchUtxosCallback()
214
228
  const utxos = useUtxos()
229
+ const accountCapabilities = useCurrentAccountCapabilities()
230
+ const { t } = useI18n()
215
231
  return useCallback(
216
232
  async ({
217
233
  toAddressInfo,
@@ -224,6 +240,9 @@ export function usePrepareSendOrdinalsInscriptionsCallback() {
224
240
  feeRate?: number
225
241
  enableRBF?: boolean
226
242
  }) => {
243
+ if (!accountCapabilities.canCreateSigningRequest) {
244
+ throw new Error(t('not_supported'))
245
+ }
227
246
  if (!feeRate) {
228
247
  const summary = await wallet.getFeeSummary()
229
248
  feeRate = summary.list[1]!.feeRate
@@ -243,7 +262,7 @@ export function usePrepareSendOrdinalsInscriptionsCallback() {
243
262
 
244
263
  return res
245
264
  },
246
- [dispatch, wallet, fromAddress, utxos]
265
+ [dispatch, wallet, fromAddress, utxos, accountCapabilities.canCreateSigningRequest, t]
247
266
  )
248
267
  }
249
268
 
@@ -254,6 +273,8 @@ export function useCreateSplitTxCallback() {
254
273
  const utxos = useUtxos()
255
274
  const fetchUtxos = useFetchUtxosCallback()
256
275
  const account = useCurrentAccount()
276
+ const accountCapabilities = useCurrentAccountCapabilities()
277
+ const { t } = useI18n()
257
278
  return useCallback(
258
279
  async ({
259
280
  inscriptionId,
@@ -266,6 +287,9 @@ export function useCreateSplitTxCallback() {
266
287
  outputValue: number
267
288
  enableRBF?: boolean
268
289
  }) => {
290
+ if (!accountCapabilities.canCreateSigningRequest) {
291
+ throw new Error(t('not_supported'))
292
+ }
269
293
  let btcUtxos = utxos
270
294
  if (btcUtxos.length === 0) {
271
295
  btcUtxos = await fetchUtxos()
@@ -281,7 +305,7 @@ export function useCreateSplitTxCallback() {
281
305
 
282
306
  return res
283
307
  },
284
- [dispatch, wallet, fromAddress, utxos]
308
+ [dispatch, wallet, fromAddress, utxos, accountCapabilities.canCreateSigningRequest, t]
285
309
  )
286
310
  }
287
311
 
@@ -394,6 +418,8 @@ export function usePrepareSendRunesCallback() {
394
418
  const assetUtxosRunes = useAssetUtxosRunes()
395
419
  const fetchAssetUtxosRunes = useFetchAssetUtxosRunesCallback()
396
420
  const account = useCurrentAccount()
421
+ const accountCapabilities = useCurrentAccountCapabilities()
422
+ const { t } = useI18n()
397
423
  return useCallback(
398
424
  async ({
399
425
  toAddressInfo,
@@ -410,6 +436,9 @@ export function usePrepareSendRunesCallback() {
410
436
  feeRate: number
411
437
  enableRBF?: boolean
412
438
  }) => {
439
+ if (!accountCapabilities.canCreateSigningRequest) {
440
+ throw new Error(t('not_supported'))
441
+ }
413
442
  if (!feeRate) {
414
443
  const summary = await wallet.getFeeSummary()
415
444
  feeRate = summary.list[1]!.feeRate
@@ -438,7 +467,17 @@ export function usePrepareSendRunesCallback() {
438
467
 
439
468
  return toSignData
440
469
  },
441
- [dispatch, wallet, fromAddress, utxos, assetUtxosRunes, fetchAssetUtxosRunes, account]
470
+ [
471
+ dispatch,
472
+ wallet,
473
+ fromAddress,
474
+ utxos,
475
+ assetUtxosRunes,
476
+ fetchAssetUtxosRunes,
477
+ account,
478
+ accountCapabilities.canCreateSigningRequest,
479
+ t,
480
+ ]
442
481
  )
443
482
  }
444
483
 
@@ -450,6 +489,8 @@ export function useRunesTx() {
450
489
  export function usePrepareSendAlkanesCallback() {
451
490
  const wallet = useWallet()
452
491
  const account = useCurrentAccount()
492
+ const accountCapabilities = useCurrentAccountCapabilities()
493
+ const { t } = useI18n()
453
494
  const callback = useCallback(
454
495
  async (
455
496
  toAddressInfo: ToAddressInfo,
@@ -459,6 +500,9 @@ export function usePrepareSendAlkanesCallback() {
459
500
  type: 'ft' | 'nft',
460
501
  enableRBF?: boolean
461
502
  ) => {
503
+ if (!accountCapabilities.canCreateSigningRequest) {
504
+ throw new Error(t('not_supported'))
505
+ }
462
506
  return await wallet.createSendAlkanesPsbt({
463
507
  to: toAddressInfo.address,
464
508
  alkaneid,
@@ -468,7 +512,7 @@ export function usePrepareSendAlkanesCallback() {
468
512
  enableRBF,
469
513
  })
470
514
  },
471
- [wallet, account]
515
+ [wallet, account, accountCapabilities.canCreateSigningRequest, t]
472
516
  )
473
517
  return callback
474
518
  }
package/src/hooks/ui.ts CHANGED
@@ -45,23 +45,26 @@ export function useUiTxCreateScreen() {
45
45
 
46
46
  export function useUpdateUiTxCreateScreen() {
47
47
  const dispatch = useAppDispatch()
48
- return ({
49
- toInfo,
50
- inputAmount,
51
- enableRBF,
52
- }: {
53
- toInfo?: { address: string; domain: string; inscription?: Inscription }
54
- inputAmount?: string
55
- enableRBF?: boolean
56
- }) => {
57
- dispatch(
58
- (uiActions as any).updateTxCreateScreen({
59
- toInfo,
60
- inputAmount,
61
- enableRBF,
62
- })
63
- )
64
- }
48
+ return useCallback(
49
+ ({
50
+ toInfo,
51
+ inputAmount,
52
+ enableRBF,
53
+ }: {
54
+ toInfo?: { address: string; domain: string; inscription?: Inscription }
55
+ inputAmount?: string
56
+ enableRBF?: boolean
57
+ }) => {
58
+ dispatch(
59
+ (uiActions as any).updateTxCreateScreen({
60
+ toInfo,
61
+ inputAmount,
62
+ enableRBF,
63
+ })
64
+ )
65
+ },
66
+ [dispatch]
67
+ )
65
68
  }
66
69
 
67
70
  export function useFeeRateBar() {
@@ -71,36 +74,39 @@ export function useFeeRateBar() {
71
74
 
72
75
  export function useUpdateFeeRateBar() {
73
76
  const dispatch = useAppDispatch()
74
- return ({
75
- feeRate,
76
- feeRateInputVal,
77
- enableLowFeeRate,
78
- feeOptionIndex,
79
- showCustomInput,
80
- }: {
81
- feeRate?: number
82
- feeRateInputVal?: string
83
- enableLowFeeRate?: boolean
84
- feeOptionIndex?: number
85
- showCustomInput?: boolean
86
- }) => {
87
- dispatch(
88
- (uiActions as any).updateFeeRateBar({
89
- feeRate,
90
- feeRateInputVal,
91
- enableLowFeeRate,
92
- feeOptionIndex,
93
- showCustomInput,
94
- })
95
- )
96
- }
77
+ return useCallback(
78
+ ({
79
+ feeRate,
80
+ feeRateInputVal,
81
+ enableLowFeeRate,
82
+ feeOptionIndex,
83
+ showCustomInput,
84
+ }: {
85
+ feeRate?: number
86
+ feeRateInputVal?: string
87
+ enableLowFeeRate?: boolean
88
+ feeOptionIndex?: number
89
+ showCustomInput?: boolean
90
+ }) => {
91
+ dispatch(
92
+ (uiActions as any).updateFeeRateBar({
93
+ feeRate,
94
+ feeRateInputVal,
95
+ enableLowFeeRate,
96
+ feeOptionIndex,
97
+ showCustomInput,
98
+ })
99
+ )
100
+ },
101
+ [dispatch]
102
+ )
97
103
  }
98
104
 
99
105
  export function useResetFeeRateBar() {
100
106
  const dispatch = useAppDispatch()
101
- return () => {
107
+ return useCallback(() => {
102
108
  dispatch((uiActions as any).resetFeeRateBar())
103
- }
109
+ }, [dispatch])
104
110
  }
105
111
 
106
112
  export function useAddressInput() {
@@ -110,21 +116,24 @@ export function useAddressInput() {
110
116
 
111
117
  export function useUpdateAddressInput() {
112
118
  const dispatch = useAppDispatch()
113
- return ({ address, domain }: { address?: string; domain?: string }) => {
114
- dispatch(
115
- (uiActions as any).updateAddressInput({
116
- address,
117
- domain,
118
- })
119
- )
120
- }
119
+ return useCallback(
120
+ ({ address, domain }: { address?: string; domain?: string }) => {
121
+ dispatch(
122
+ (uiActions as any).updateAddressInput({
123
+ address,
124
+ domain,
125
+ })
126
+ )
127
+ },
128
+ [dispatch]
129
+ )
121
130
  }
122
131
 
123
132
  export function useResetAddressInput() {
124
133
  const dispatch = useAppDispatch()
125
- return () => {
134
+ return useCallback(() => {
126
135
  dispatch((uiActions as any).resetAddressInput())
127
- }
136
+ }, [dispatch])
128
137
  }
129
138
 
130
139
  export function useAmountInput() {
@@ -134,35 +143,38 @@ export function useAmountInput() {
134
143
 
135
144
  export function useUpdateAmountInput() {
136
145
  const dispatch = useAppDispatch()
137
- return ({ amount }: { amount?: string }) => {
138
- dispatch(
139
- (uiActions as any).updateAmountInput({
140
- amount,
141
- })
142
- )
143
- }
146
+ return useCallback(
147
+ ({ amount }: { amount?: string }) => {
148
+ dispatch(
149
+ (uiActions as any).updateAmountInput({
150
+ amount,
151
+ })
152
+ )
153
+ },
154
+ [dispatch]
155
+ )
144
156
  }
145
157
 
146
158
  export function useResetAmountInput() {
147
159
  const dispatch = useAppDispatch()
148
- return () => {
160
+ return useCallback(() => {
149
161
  dispatch((uiActions as any).resetAmountInput())
150
- }
162
+ }, [dispatch])
151
163
  }
152
164
 
153
165
  export function useResetTxState() {
154
166
  const dispatch = useAppDispatch()
155
- return () => {
167
+ return useCallback(() => {
156
168
  dispatch((uiActions as any).resetTxCreateScreen())
157
169
  dispatch((uiActions as any).resetFeeRateBar())
158
- }
170
+ }, [dispatch])
159
171
  }
160
172
 
161
173
  export function useResetUiTxCreateScreen() {
162
174
  const dispatch = useAppDispatch()
163
- return () => {
175
+ return useCallback(() => {
164
176
  dispatch((uiActions as any).resetTxCreateScreen())
165
- }
177
+ }, [dispatch])
166
178
  }
167
179
 
168
180
  export const useThrottle = (callback, delay, lastCallRef) => {
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'
2
2
 
3
3
  import { numUtils } from '@unisat/base-utils'
4
4
  import { ADDRESS_TYPES, KeyringType } from '@unisat/keyring-service/types'
5
- import { getAccountDerivationPath } from '@unisat/wallet-shared'
5
+ import { getAccountCapabilities, getAccountDerivationPath } from '@unisat/wallet-shared'
6
6
  import { AddressType } from '@unisat/wallet-types'
7
7
  import {
8
8
  useAppDispatch,
@@ -29,6 +29,10 @@ export function useAddressTypeScreenLogic() {
29
29
  const wallet = useWallet()
30
30
  const currentKeyring = useCurrentKeyring()
31
31
  const account = useCurrentAccount()
32
+ const currentKeyringCapabilities = useMemo(
33
+ () => getAccountCapabilities({ type: currentKeyring.type }),
34
+ [currentKeyring.type]
35
+ )
32
36
 
33
37
  const nav = useNavigation()
34
38
  const dispatch = useAppDispatch()
@@ -77,8 +81,8 @@ export function useAddressTypeScreenLogic() {
77
81
  }, [])
78
82
 
79
83
  const addressTypes = useMemo(() => {
80
- // Cold wallets do not allow switching address types, only show the current type
81
- if (currentKeyring.type === KeyringType.ColdWalletKeyring) {
84
+ // Wallets backed by a fixed address do not allow switching address types.
85
+ if (!currentKeyringCapabilities.canChangeAddressType) {
82
86
  return ADDRESS_TYPES.filter(v => v.value === currentKeyring.addressType)
83
87
  }
84
88
 
@@ -105,7 +109,14 @@ export function useAddressTypeScreenLogic() {
105
109
  (a, b) => a.displayIndex - b.displayIndex
106
110
  )
107
111
  }
108
- }, [currentKeyring.type, currentKeyring.addressType, addressAssets, addresses])
112
+ }, [
113
+ currentKeyring.type,
114
+ currentKeyring.addressType,
115
+ currentKeyringCapabilities.canChangeAddressType,
116
+ currentKeyring.accountIndexDerivation,
117
+ addressAssets,
118
+ addresses,
119
+ ])
109
120
 
110
121
  const items: AddressTypeItem[] = useMemo(() => {
111
122
  return addressTypes.map(v => {
@@ -115,7 +126,11 @@ export function useAddressTypeScreenLogic() {
115
126
  satoshis: 0,
116
127
  total_inscription: 0,
117
128
  }
118
- const derivedPath = getAccountDerivationPath(v.hdPath, account.index || 0, currentKeyring.accountIndexDerivation)
129
+ const derivedPath = getAccountDerivationPath(
130
+ v.hdPath,
131
+ account.index || 0,
132
+ currentKeyring.accountIndexDerivation
133
+ )
119
134
  let name = `${v.name} (${derivedPath})`
120
135
  if (currentKeyring.type === KeyringType.SimpleKeyring) {
121
136
  name = `${v.name}`
@@ -137,9 +152,8 @@ export function useAddressTypeScreenLogic() {
137
152
  return
138
153
  }
139
154
 
140
- // Cold wallets do not allow switching address types
141
- if (currentKeyring.type === KeyringType.ColdWalletKeyring) {
142
- tools.toastError(t('Cold wallet address type cannot be changed'))
155
+ if (!currentKeyringCapabilities.canChangeAddressType) {
156
+ tools.toastError(t('not_supported'))
143
157
  return
144
158
  }
145
159
 
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'react'
2
2
  import { useI18n, useNavigation, useWallet } from 'src/context'
3
- import { useResetTxState } from 'src/hooks'
3
+ import { useCurrentAccountCapabilities, useResetTxState } from 'src/hooks'
4
4
 
5
5
  export function useAlkanesNFTScreenLogic() {
6
6
  const nav = useNavigation()
@@ -9,6 +9,7 @@ export function useAlkanesNFTScreenLogic() {
9
9
  const { t } = useI18n()
10
10
 
11
11
  const resetTxState = useResetTxState()
12
+ const accountCapabilities = useCurrentAccountCapabilities()
12
13
 
13
14
  const [availableUtxo, setAvailableUtxo] = useState(0)
14
15
  const wallet = useWallet()
@@ -32,7 +33,7 @@ export function useAlkanesNFTScreenLogic() {
32
33
  })
33
34
  }
34
35
 
35
- const disabledSend = availableUtxo <= 0
36
+ const disabledSend = !accountCapabilities.canCreateSigningRequest || availableUtxo <= 0
36
37
 
37
38
  return {
38
39
  alkanesInfo,
@@ -5,6 +5,7 @@ import {
5
5
  useAlkanesIconInfo,
6
6
  useAlkanesTokenInfoExplorerUrl,
7
7
  useCurrentAccount,
8
+ useCurrentAccountCapabilities,
8
9
  useI18n,
9
10
  useNavigation,
10
11
  useResetTxState,
@@ -48,6 +49,7 @@ export function useAlkanesTokenScreenLogic() {
48
49
  const wallet = useWallet()
49
50
 
50
51
  const account = useCurrentAccount()
52
+ const accountCapabilities = useCurrentAccountCapabilities()
51
53
 
52
54
  const [loading, setLoading] = useState(true)
53
55
 
@@ -70,11 +72,11 @@ export function useAlkanesTokenScreenLogic() {
70
72
 
71
73
  const enableTransfer = useMemo(() => {
72
74
  let enable = false
73
- if (tokenSummary.tokenBalance.amount !== '0') {
75
+ if (accountCapabilities.canCreateSigningRequest && tokenSummary.tokenBalance.amount !== '0') {
74
76
  enable = true
75
77
  }
76
78
  return enable
77
- }, [tokenSummary])
79
+ }, [accountCapabilities.canCreateSigningRequest, tokenSummary])
78
80
 
79
81
  const tools = useTools()
80
82
 
@@ -6,6 +6,7 @@ import {
6
6
  useChain,
7
7
  useChainType,
8
8
  useCurrentAccount,
9
+ useCurrentAccountCapabilities,
9
10
  useI18n,
10
11
  useNavigation,
11
12
  useResetTxState,
@@ -205,6 +206,7 @@ export function useBRC20TokenScreenLogic() {
205
206
  const wallet = useWallet()
206
207
 
207
208
  const account = useCurrentAccount()
209
+ const accountCapabilities = useCurrentAccountCapabilities()
208
210
 
209
211
  const [loading, setLoading] = useState(true)
210
212
 
@@ -257,13 +259,14 @@ export function useBRC20TokenScreenLogic() {
257
259
  const enableTransfer = useMemo(() => {
258
260
  let enable = false
259
261
  if (
262
+ accountCapabilities.canCreateSigningRequest &&
260
263
  tokenSummary.tokenBalance.overallBalance !== '0' &&
261
264
  tokenSummary.tokenBalance.overallBalance !== ''
262
265
  ) {
263
266
  enable = true
264
267
  }
265
268
  return enable
266
- }, [tokenSummary])
269
+ }, [accountCapabilities.canCreateSigningRequest, tokenSummary])
267
270
 
268
271
  const tools = useTools()
269
272
  const chainType = useChainType()