@unisat/wallet-state 1.1.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 (45) hide show
  1. package/lib/index.d.mts +87 -18
  2. package/lib/index.d.ts +87 -18
  3. package/lib/index.js +516 -175
  4. package/lib/index.js.map +1 -1
  5. package/lib/index.mjs +514 -178
  6. package/lib/index.mjs.map +1 -1
  7. package/lib/types/index.d.mts +6 -2
  8. package/lib/types/index.d.ts +6 -2
  9. package/lib/types/index.js +7 -1
  10. package/lib/types/index.js.map +1 -1
  11. package/lib/types/index.mjs +7 -2
  12. package/lib/types/index.mjs.map +1 -1
  13. package/package.json +4 -4
  14. package/src/context/NavigationContext.tsx +1 -0
  15. package/src/context/WalletContext.tsx +56 -23
  16. package/src/hooks/accounts.ts +7 -2
  17. package/src/hooks/settings.ts +10 -0
  18. package/src/hooks/transactions.ts +75 -10
  19. package/src/hooks/ui.ts +83 -63
  20. package/src/reducers/accounts.ts +3 -0
  21. package/src/reducers/ui.ts +21 -0
  22. package/src/types/ui.ts +6 -1
  23. package/src/ui-hooks/useAddressTypeScreenLogic.ts +22 -8
  24. package/src/ui-hooks/useAlkanesNFTScreenLogic.ts +3 -2
  25. package/src/ui-hooks/useAlkanesTokenScreenLogic.ts +12 -2
  26. package/src/ui-hooks/useBRC20InscribeTransferLogic.ts +30 -10
  27. package/src/ui-hooks/useBRC20ListLogic.ts +6 -2
  28. package/src/ui-hooks/useBRC20ProgListLogic.ts +7 -3
  29. package/src/ui-hooks/useBRC20SendScreenLogic.ts +19 -6
  30. package/src/ui-hooks/useBRC20TokenScreenLogic.ts +48 -25
  31. package/src/ui-hooks/useCAT20TokenScreenLogic.ts +16 -2
  32. package/src/ui-hooks/useCAT721NFTScreenLogic.ts +3 -1
  33. package/src/ui-hooks/useEditAccountNameScreenLogic.ts +4 -4
  34. package/src/ui-hooks/useEditWalletNameScreenLogic.ts +5 -3
  35. package/src/ui-hooks/useOrdinalsInscriptionScreenLogic.ts +3 -2
  36. package/src/ui-hooks/useRunesTokenScreenLogic.ts +11 -2
  37. package/src/ui-hooks/useSendAlkanesNFTScreenLogic.ts +24 -2
  38. package/src/ui-hooks/useSendAlkanesScreenLogic.ts +17 -1
  39. package/src/ui-hooks/useSendOrdinalsInscriptionScreenLogic.ts +17 -5
  40. package/src/ui-hooks/useSendRunesScreenLogic.ts +18 -1
  41. package/src/ui-hooks/useSettingsTabScreenLogic.ts +18 -3
  42. package/src/ui-hooks/useSignMessageLogic.ts +37 -16
  43. package/src/ui-hooks/useSignPsbtLogic.ts +31 -15
  44. package/src/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.ts +15 -1
  45. package/src/ui-hooks/useTxCreateScreenLogic.ts +17 -1
@@ -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,
@@ -3,7 +3,9 @@ import { useEffect, useMemo, useState } from 'react'
3
3
  import { AddressAlkanesTokenSummary } from '@unisat/wallet-shared'
4
4
  import {
5
5
  useAlkanesIconInfo,
6
+ useAlkanesTokenInfoExplorerUrl,
6
7
  useCurrentAccount,
8
+ useCurrentAccountCapabilities,
7
9
  useI18n,
8
10
  useNavigation,
9
11
  useResetTxState,
@@ -47,6 +49,7 @@ export function useAlkanesTokenScreenLogic() {
47
49
  const wallet = useWallet()
48
50
 
49
51
  const account = useCurrentAccount()
52
+ const accountCapabilities = useCurrentAccountCapabilities()
50
53
 
51
54
  const [loading, setLoading] = useState(true)
52
55
 
@@ -69,11 +72,11 @@ export function useAlkanesTokenScreenLogic() {
69
72
 
70
73
  const enableTransfer = useMemo(() => {
71
74
  let enable = false
72
- if (tokenSummary.tokenBalance.amount !== '0') {
75
+ if (accountCapabilities.canCreateSigningRequest && tokenSummary.tokenBalance.amount !== '0') {
73
76
  enable = true
74
77
  }
75
78
  return enable
76
- }, [tokenSummary])
79
+ }, [accountCapabilities.canCreateSigningRequest, tokenSummary])
77
80
 
78
81
  const tools = useTools()
79
82
 
@@ -112,6 +115,12 @@ export function useAlkanesTokenScreenLogic() {
112
115
  tokenSummary.tokenBalance.alkaneid
113
116
  )
114
117
 
118
+ const alkanesExplorerUrl = useAlkanesTokenInfoExplorerUrl(tokenSummary.tokenInfo.alkaneid)
119
+
120
+ const onClickViewOnExplorer = () => {
121
+ nav.navToUrl(alkanesExplorerUrl)
122
+ }
123
+
115
124
  return {
116
125
  tokenSummary,
117
126
  loading,
@@ -125,6 +134,7 @@ export function useAlkanesTokenScreenLogic() {
125
134
  onClickMint,
126
135
  onClickSend,
127
136
  onClickTrade,
137
+ onClickViewOnExplorer,
128
138
  iconInfo,
129
139
  }
130
140
  }
@@ -39,6 +39,7 @@ interface ContextData {
39
39
  isApproval: boolean
40
40
  tokenInfo?: TokenInfo
41
41
  amountEditable?: boolean
42
+ enableRBF: boolean
42
43
  }
43
44
 
44
45
  interface UpdateContextDataParams {
@@ -51,6 +52,7 @@ interface UpdateContextDataParams {
51
52
  amount?: string
52
53
  tokenInfo?: TokenInfo
53
54
  amountEditable?: boolean
55
+ enableRBF?: boolean
54
56
  }
55
57
 
56
58
  export interface BRC20InscribeTransferParams {
@@ -66,13 +68,11 @@ export function useBRC20InscribeTransferLogic() {
66
68
  step: Step.STEP1,
67
69
  ticker: ticker,
68
70
  isApproval: false,
71
+ enableRBF: true,
69
72
  })
70
- const updateContextData = useCallback(
71
- (params: UpdateContextDataParams) => {
72
- setContextData(Object.assign({}, contextData, params))
73
- },
74
- [contextData, setContextData]
75
- )
73
+ const updateContextData = useCallback((params: UpdateContextDataParams) => {
74
+ setContextData(prev => Object.assign({}, prev, params))
75
+ }, [])
76
76
  return {
77
77
  contextData,
78
78
  updateContextData,
@@ -122,6 +122,12 @@ export function useBRC20InscribeTransferLogicStep1(params: BRC20InscribeTransfer
122
122
  }
123
123
  }, [])
124
124
 
125
+ useEffect(() => {
126
+ wallet.getEnableRBF().then(enableRBF => {
127
+ updateContextData({ enableRBF })
128
+ })
129
+ }, [])
130
+
125
131
  useEffect(() => {
126
132
  setInputError('')
127
133
  setInputErrorAvailable('')
@@ -180,7 +186,10 @@ export function useBRC20InscribeTransferLogicStep1(params: BRC20InscribeTransfer
180
186
  fetchUtxos()
181
187
 
182
188
  wallet
183
- .getBRC20Summary(account.address, contextData.ticker)
189
+ .getBRC20Summary({
190
+ address: account.address,
191
+ ticker: contextData.ticker,
192
+ })
184
193
  .then(v => {
185
194
  updateContextData({ tokenBalance: v.tokenBalance, tokenInfo: v.tokenInfo })
186
195
  setTimeout(() => {
@@ -208,6 +217,7 @@ export function useBRC20InscribeTransferLogicStep1(params: BRC20InscribeTransfer
208
217
  toAddressInfo: { address: order.payAddress, domain: '' },
209
218
  toAmount: order.totalFee,
210
219
  feeRate: feeRateBarState.feeRate,
220
+ enableRBF: contextData.enableRBF,
211
221
  })
212
222
  updateContextData({ order, amount, toSignData, step: Step.STEP2 })
213
223
  } catch (e) {
@@ -230,6 +240,11 @@ export function useBRC20InscribeTransferLogicStep1(params: BRC20InscribeTransfer
230
240
  defaultOutputValue,
231
241
  setOutputValue,
232
242
  disabled,
243
+ enableRBF: contextData.enableRBF,
244
+ setEnableRBF: (value: boolean) => {
245
+ updateContextData({ enableRBF: value })
246
+ wallet.setEnableRBF(value)
247
+ },
233
248
  loadingOnly,
234
249
  handleCancel,
235
250
  }
@@ -316,9 +331,11 @@ export function useBRC20InscribeTransferLogicStep3(params: BRC20InscribeTransfer
316
331
  const onSignPsbtHandleConfirm = async (signedDatas: SignedData[]) => {
317
332
  tools.showLoading(true)
318
333
  try {
319
- const { success, txid, error } = await pushBitcoinTx(signedDatas[0].psbtHex)
334
+ const { success, error } = await pushBitcoinTx(signedDatas[0].psbtHex)
320
335
  if (success) {
321
- nav.navigate('TxSuccessScreen', { txid })
336
+ updateContextData({
337
+ step: Step.STEP4,
338
+ })
322
339
  } else {
323
340
  throw new Error(error)
324
341
  }
@@ -367,7 +384,10 @@ export function useBRC20InscribeTransferLogicStep4(params: BRC20InscribeTransfer
367
384
  const onClickConfirm = () => {
368
385
  tools.showLoading(true)
369
386
  wallet
370
- .getBRC20Summary(currentAccount.address, tokenBalance.ticker)
387
+ .getBRC20Summary({
388
+ address: currentAccount.address,
389
+ ticker: tokenBalance.ticker,
390
+ })
371
391
  .then(v => {
372
392
  if (contextData.isApproval) {
373
393
  resolveApproval({
@@ -6,8 +6,8 @@ import {
6
6
  useCurrentAccount,
7
7
  useNavigation,
8
8
  useOrdinalsAssetTabKey,
9
- useWallet,
10
9
  useWallTabFocusRefresh,
10
+ useWallet,
11
11
  } from '..'
12
12
  import { useInfiniteList } from './useInfiniteList'
13
13
 
@@ -41,7 +41,11 @@ export function useBRC20ListLogic() {
41
41
  if (currentAccount.address === '') {
42
42
  return { list: [], total: 0 }
43
43
  }
44
- const { list, total } = await wallet.getBRC20List(currentAccount.address, page, pageSize)
44
+ const { list, total } = await wallet.getBRC20List({
45
+ address: currentAccount.address,
46
+ currentPage: page,
47
+ pageSize,
48
+ })
45
49
  if (list.length > 0) {
46
50
  wallet.getBrc20sPrice(list.map(item => item.ticker)).then(updatePrices)
47
51
  }
@@ -1,14 +1,14 @@
1
1
  import { TickPriceItem, TokenBalance } from '@unisat/wallet-shared'
2
2
  import { useEffect, useRef, useState } from 'react'
3
3
  import {
4
- getSupportedAssets,
5
4
  OrdinalsAssetTabKey,
5
+ getSupportedAssets,
6
6
  useChainType,
7
7
  useCurrentAccount,
8
8
  useNavigation,
9
9
  useOrdinalsAssetTabKey,
10
- useWallet,
11
10
  useWallTabFocusRefresh,
11
+ useWallet,
12
12
  } from '..'
13
13
  import { useInfiniteList } from './useInfiniteList'
14
14
 
@@ -43,7 +43,11 @@ export function useBRC20ProgListLogic() {
43
43
  return { list: [], total: 0 }
44
44
  }
45
45
 
46
- const { list, total } = await wallet.getBRC20ProgList(currentAccount.address, page, pageSize)
46
+ const { list, total } = await wallet.getBRC20ProgList({
47
+ address: currentAccount.address,
48
+ currentPage: page,
49
+ pageSize,
50
+ })
47
51
  if (list.length > 0) {
48
52
  wallet.getBrc20sPrice(list.map(item => item.ticker)).then(updatePrices)
49
53
  }
@@ -31,6 +31,7 @@ export interface ContextData {
31
31
  transferableList: TokenTransfer[]
32
32
  inscriptionIdSet: Set<string>
33
33
  receiver: string
34
+ enableRBF: boolean
34
35
  rawTxInfo: RawTxInfo
35
36
  tokenInfo: TokenInfo
36
37
  }
@@ -42,6 +43,7 @@ export interface UpdateContextDataParams {
42
43
  transferableList?: TokenTransfer[]
43
44
  inscriptionIdSet?: Set<string>
44
45
  receiver?: string
46
+ enableRBF?: boolean
45
47
  rawTxInfo?: RawTxInfo
46
48
  }
47
49
 
@@ -52,6 +54,7 @@ export interface BRC20SendStepParams {
52
54
 
53
55
  export function useBRC20SendScreenLogic() {
54
56
  const nav = useNavigation()
57
+ const wallet = useWallet()
55
58
 
56
59
  const props = nav.getRouteState<'BRC20SendScreen'>()
57
60
 
@@ -66,6 +69,7 @@ export function useBRC20SendScreenLogic() {
66
69
  transferableList: [],
67
70
  inscriptionIdSet: new Set(selectedInscriptionIds),
68
71
  receiver: '',
72
+ enableRBF: true,
69
73
  rawTxInfo: {
70
74
  psbtHex: '',
71
75
  rawtx: '',
@@ -111,6 +115,12 @@ export function useBRC20SendScreenLogic() {
111
115
 
112
116
  const { t } = useI18n()
113
117
 
118
+ useEffect(() => {
119
+ wallet.getEnableRBF().then(enableRBF => {
120
+ updateContextData({ enableRBF })
121
+ })
122
+ }, [wallet, updateContextData])
123
+
114
124
  return {
115
125
  t,
116
126
  contextData,
@@ -195,6 +205,7 @@ export function useBRC20SendScreenLogicStep2({
195
205
  inscriptionId: inscriptionIds[0],
196
206
  feeRate: feeRateBar.feeRate,
197
207
  outputValue: getAddressUtxoDust(contextData.receiver),
208
+ enableRBF: contextData.enableRBF,
198
209
  })
199
210
  nav.navigate('TxConfirmScreen', { toSignData })
200
211
  } else {
@@ -202,6 +213,7 @@ export function useBRC20SendScreenLogicStep2({
202
213
  toAddressInfo: { address: contextData.receiver, domain: '' },
203
214
  inscriptionIds,
204
215
  feeRate: feeRateBar.feeRate,
216
+ enableRBF: contextData.enableRBF,
205
217
  })
206
218
  nav.navigate('TxConfirmScreen', { toSignData })
207
219
  }
@@ -296,12 +308,13 @@ export function useTransferableListLogic({ contextData, updateContextData }: BRC
296
308
  const fetchData = async () => {
297
309
  try {
298
310
  setLoading(true)
299
- const { list, total } = await wallet.getBRC20TransferableList(
300
- currentAccount.address,
301
- contextData.tokenBalance.ticker,
302
- pagination.currentPage,
303
- pagination.pageSize
304
- )
311
+ const { list, total } = await wallet.getBRC20TransferableList({
312
+ address: currentAccount.address,
313
+ ticker: contextData.tokenBalance.ticker,
314
+ tickerHex: contextData.tokenBalance.tickerHex,
315
+ currentPage: pagination.currentPage,
316
+ pageSize: pagination.pageSize,
317
+ })
305
318
  setItems(list)
306
319
  setTotal(total)
307
320
  } catch (e) {
@@ -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,
@@ -29,6 +30,8 @@ export interface BRC20OutWalletBalanceItem {
29
30
  amount: string
30
31
  }
31
32
 
33
+ const INSWAP_SWAP_ANCHOR = '#swap'
34
+
32
35
  export function useBRC20TokenHistoryLogic(props: { ticker: string; displayName?: string }) {
33
36
  const wallet = useWallet()
34
37
  const { t } = useI18n()
@@ -178,6 +181,7 @@ export function useBRC20TokenScreenLogic() {
178
181
  const [tokenSummary, setTokenSummary] = useState<AddressTokenSummary>({
179
182
  tokenBalance: {
180
183
  ticker,
184
+ tickerHex: Buffer.from(ticker).toString('hex'),
181
185
  overallBalance: '',
182
186
  availableBalance: '',
183
187
  transferableBalance: '',
@@ -202,6 +206,7 @@ export function useBRC20TokenScreenLogic() {
202
206
  const wallet = useWallet()
203
207
 
204
208
  const account = useCurrentAccount()
209
+ const accountCapabilities = useCurrentAccountCapabilities()
205
210
 
206
211
  const [loading, setLoading] = useState(true)
207
212
 
@@ -210,7 +215,10 @@ export function useBRC20TokenScreenLogic() {
210
215
  const resetTxState = useResetTxState()
211
216
  useEffect(() => {
212
217
  wallet
213
- .getBRC20Summary(account.address, ticker)
218
+ .getBRC20Summary({
219
+ address: account.address,
220
+ ticker,
221
+ })
214
222
  .then(tokenSummary => {
215
223
  if (tokenSummary.tokenInfo.holder == account.address) {
216
224
  wallet
@@ -251,13 +259,14 @@ export function useBRC20TokenScreenLogic() {
251
259
  const enableTransfer = useMemo(() => {
252
260
  let enable = false
253
261
  if (
262
+ accountCapabilities.canCreateSigningRequest &&
254
263
  tokenSummary.tokenBalance.overallBalance !== '0' &&
255
264
  tokenSummary.tokenBalance.overallBalance !== ''
256
265
  ) {
257
266
  enable = true
258
267
  }
259
268
  return enable
260
- }, [tokenSummary])
269
+ }, [accountCapabilities.canCreateSigningRequest, tokenSummary])
261
270
 
262
271
  const tools = useTools()
263
272
  const chainType = useChainType()
@@ -308,8 +317,14 @@ export function useBRC20TokenScreenLogic() {
308
317
  }
309
318
  }, [t, enableHistory])
310
319
 
320
+ const showSwapBalance = chain.isFractal
321
+ const showProgBalance = chain.enableBrc20Prog
322
+ const swapSiteEnabled = chain.enum === ChainType.FRACTAL_BITCOIN_MAINNET
323
+ const progSiteEnabled = chain.enum === ChainType.BITCOIN_MAINNET
324
+
311
325
  const onSwapBalance = tokenSummary?.tokenBalance?.swapBalance
312
326
  const onProgBalance = tokenSummary?.tokenBalance?.progBalance
327
+
313
328
  const inWalletBalance = tokenSummary?.tokenBalance?.overallBalance
314
329
  const outWalletBalanceItems = useMemo<BRC20OutWalletBalanceItem[]>(() => {
315
330
  const items: BRC20OutWalletBalanceItem[] = [
@@ -320,7 +335,7 @@ export function useBRC20TokenScreenLogic() {
320
335
  },
321
336
  ]
322
337
 
323
- if (onSwapBalance && onSwapBalance !== '0') {
338
+ if (showSwapBalance) {
324
339
  items.push({
325
340
  key: 'swap',
326
341
  label: t('brc20_on_swap'),
@@ -328,7 +343,7 @@ export function useBRC20TokenScreenLogic() {
328
343
  })
329
344
  }
330
345
 
331
- if (onProgBalance && onProgBalance !== '0') {
346
+ if (showProgBalance) {
332
347
  items.push({
333
348
  key: 'prog',
334
349
  label: t('brc20_on_prog'),
@@ -348,56 +363,64 @@ export function useBRC20TokenScreenLogic() {
348
363
  .toString()
349
364
  }, [onSwapBalance, onProgBalance, inWalletBalance])
350
365
 
351
- let hasOutWalletBalance = false
352
- if (onSwapBalance && onSwapBalance !== '0') {
353
- hasOutWalletBalance = true
354
- }
355
- if (onProgBalance && onProgBalance !== '0') {
356
- hasOutWalletBalance = true
366
+ const brc20prog_ticker = encodeURIComponent(ticker)
367
+ const ensureSiteEnabled = (enabled: boolean) => {
368
+ if (!enabled) {
369
+ tools.toastError(t('not_supported'))
370
+ return false
371
+ }
372
+ return true
357
373
  }
358
374
 
375
+ // brc20prog
359
376
  const onClickWrapBrc20Prog = () => {
360
- const url = `https://link.unisat.space/btc/wrap?tick=${encodeURIComponent(ticker)}`
377
+ if (!ensureSiteEnabled(progSiteEnabled)) return
378
+ const url = `https://link.unisat.space/btc/wrap?tick=${brc20prog_ticker}`
361
379
  nav.navToUrl(url)
362
380
  }
363
381
 
364
382
  const onClickUnwrapBrc20Prog = () => {
365
- const url = `https://link.unisat.space/btc/wrap?action=unwrap&tick=${encodeURIComponent(ticker)}`
383
+ if (!ensureSiteEnabled(progSiteEnabled)) return
384
+ const url = `https://link.unisat.space/btc/wrap?action=unwrap&tick=${brc20prog_ticker}`
366
385
  nav.navToUrl(url)
367
386
  }
368
387
 
369
388
  const onClickSendBrc20Prog = () => {
370
- const url = `https://bestinslot.xyz/brc2.0/${encodeURIComponent(ticker)}/transfer`
389
+ if (!ensureSiteEnabled(progSiteEnabled)) return
390
+ const url = `https://bestinslot.xyz/brc2.0/${brc20prog_ticker}/transfer`
371
391
  nav.navToUrl(url)
372
392
  }
373
393
 
394
+ const inswap_ticker = encodeURIComponent(ticker)
395
+
396
+ // inswap
374
397
  const onClickSwapInSwap = () => {
375
- const url = `https://inswap.cc/swap?t0=${encodeURIComponent(ticker)}`
398
+ if (!ensureSiteEnabled(swapSiteEnabled)) return
399
+ const url = `https://inswap.cc/swap/pools?q=${inswap_ticker}`
376
400
  nav.navToUrl(url)
377
401
  }
378
402
 
379
403
  const onClickAddLiquidityInSwap = () => {
380
- const url = `https://inswap.cc/swap/pools?t0=${encodeURIComponent(ticker)}&t1=sFB___000&action=add`
381
- nav.navToUrl(url)
382
- }
383
-
384
- const onClickRemoveLiquidityInSwap = () => {
385
- const url = `https://inswap.cc/swap/pools?t0=${encodeURIComponent(ticker)}&t1=sFB___000&action=remove`
404
+ if (!ensureSiteEnabled(swapSiteEnabled)) return
405
+ const url = `https://inswap.cc/swap/pools?q=${inswap_ticker}`
386
406
  nav.navToUrl(url)
387
407
  }
388
408
 
389
409
  const onClickWrapInSwap = () => {
390
- const url = `https://inswap.cc/swap?tab=deposit&t=${encodeURIComponent(ticker)}`
410
+ if (!ensureSiteEnabled(swapSiteEnabled)) return
411
+ const url = `https://inswap.cc/swap?tab=deposit&t=${inswap_ticker}${INSWAP_SWAP_ANCHOR}`
391
412
  nav.navToUrl(url)
392
413
  }
393
414
 
394
415
  const onClickUnwrapInSwap = () => {
395
- const url = `https://inswap.cc/swap?tab=withdraw&t=${encodeURIComponent(ticker)}`
416
+ if (!ensureSiteEnabled(swapSiteEnabled)) return
417
+ const url = `https://inswap.cc/swap?tab=withdraw&t=${inswap_ticker}${INSWAP_SWAP_ANCHOR}`
396
418
  nav.navToUrl(url)
397
419
  }
398
420
 
399
421
  const onClickSendInSwap = () => {
400
- const url = `https://inswap.cc/swap/assets/account`
422
+ if (!ensureSiteEnabled(swapSiteEnabled)) return
423
+ const url = `https://inswap.cc/swap/assets/account?tab=assets&t=${inswap_ticker}&action=send`
401
424
  nav.navToUrl(url)
402
425
  }
403
426
 
@@ -433,7 +456,6 @@ export function useBRC20TokenScreenLogic() {
433
456
  onProgBalance,
434
457
  inWalletBalance,
435
458
  outWalletBalanceItems,
436
- hasOutWalletBalance,
437
459
  enableHistory,
438
460
  enableTrade,
439
461
  enableMint,
@@ -450,13 +472,14 @@ export function useBRC20TokenScreenLogic() {
450
472
  tools,
451
473
  isBrc20Prog,
452
474
  iconInfo,
475
+ showProgBalance,
476
+ showSwapBalance,
453
477
  onClickWrapBrc20Prog,
454
478
  onClickUnwrapBrc20Prog,
455
479
  onClickSendBrc20Prog,
456
480
 
457
481
  onClickSwapInSwap,
458
482
  onClickAddLiquidityInSwap,
459
- onClickRemoveLiquidityInSwap,
460
483
  onClickWrapInSwap,
461
484
  onClickUnwrapInSwap,
462
485
  onClickSendInSwap,
@@ -9,6 +9,7 @@ import {
9
9
  useCAT20TokenInfoExplorerUrl,
10
10
  useChainType,
11
11
  useCurrentAccount,
12
+ useCurrentAccountCapabilities,
12
13
  useCurrentKeyring,
13
14
  useResetTxState,
14
15
  } from 'src/hooks'
@@ -39,6 +40,7 @@ export function useCAT20TokenScreenLogic() {
39
40
 
40
41
  const account = useCurrentAccount()
41
42
  const keyring = useCurrentKeyring()
43
+ const accountCapabilities = useCurrentAccountCapabilities()
42
44
  const [loading, setLoading] = useState(true)
43
45
  const tools = useTools()
44
46
  useEffect(() => {
@@ -52,11 +54,13 @@ export function useCAT20TokenScreenLogic() {
52
54
 
53
55
  const enableTransfer = useMemo(() => {
54
56
  let enable = false
55
- if (tokenSummary.cat20Balance && tokenSummary.cat20Balance.amount !== '0') {
57
+ if (accountCapabilities.canCreateSigningRequest && tokenSummary.cat20Balance && tokenSummary.cat20Balance.amount !== '0') {
56
58
  enable = true
57
59
  }
58
60
  return enable
59
- }, [tokenSummary])
61
+ }, [accountCapabilities.canCreateSigningRequest, tokenSummary])
62
+
63
+ const enableMerge = accountCapabilities.canCreateSigningRequest
60
64
 
61
65
  const chainType = useChainType()
62
66
  const enableTrade = useMemo(() => {
@@ -75,6 +79,10 @@ export function useCAT20TokenScreenLogic() {
75
79
  }
76
80
 
77
81
  const onClickMerge = e => {
82
+ if (!accountCapabilities.canCreateSigningRequest) {
83
+ tools.toastError(t('not_supported'))
84
+ return
85
+ }
78
86
  if (keyring.type === KeyringType.KeystoneKeyring) {
79
87
  tools.toastError(t('merge_utxos_is_not_supported_for_keystone_yet'))
80
88
  return
@@ -104,6 +112,10 @@ export function useCAT20TokenScreenLogic() {
104
112
  nav.navToUrl(marketPlaceUrl)
105
113
  }
106
114
 
115
+ const onClickViewOnExplorer = e => {
116
+ nav.navToUrl(tokenUrl)
117
+ }
118
+
107
119
  const iconInfo = useCAT20IconInfo(tokenSummary.cat20Info.name, tokenSummary.cat20Info.tokenId)
108
120
 
109
121
  return {
@@ -111,12 +123,14 @@ export function useCAT20TokenScreenLogic() {
111
123
  loading,
112
124
  tokenUrl,
113
125
  enableTransfer,
126
+ enableMerge,
114
127
  enableTrade,
115
128
  iconInfo,
116
129
  onClickMerge,
117
130
  onClickSend,
118
131
  onClickTrade,
119
132
  onClickBack,
133
+ onClickViewOnExplorer,
120
134
  t,
121
135
  }
122
136
  }
@@ -1,5 +1,5 @@
1
1
  import { useI18n, useNavigation } from 'src/context'
2
- import { useResetTxState } from 'src/hooks'
2
+ import { useCurrentAccountCapabilities, useResetTxState } from 'src/hooks'
3
3
 
4
4
  export function useCAT721NFTScreenLogic() {
5
5
  const nav = useNavigation()
@@ -8,6 +8,7 @@ export function useCAT721NFTScreenLogic() {
8
8
  const { t } = useI18n()
9
9
 
10
10
  const resetTxState = useResetTxState()
11
+ const accountCapabilities = useCurrentAccountCapabilities()
11
12
 
12
13
  const onClickBack = () => {
13
14
  nav.goBack()
@@ -33,5 +34,6 @@ export function useCAT721NFTScreenLogic() {
33
34
  // actions
34
35
  onClickBack,
35
36
  onClickSend,
37
+ disabledSend: !accountCapabilities.canCreateSigningRequest,
36
38
  }
37
39
  }
@@ -1,4 +1,4 @@
1
- import { Account } from '@unisat/wallet-shared'
1
+ import { Account, MAX_ALIAS_NAME_LENGTH } from '@unisat/wallet-shared'
2
2
  import { useMemo, useState } from 'react'
3
3
  import { useLocation } from 'react-router-dom'
4
4
  import { useI18n, useNavigation, useWallet } from 'src/context'
@@ -41,15 +41,15 @@ export function useEditAccountNameScreenLogic() {
41
41
 
42
42
  const truncatedTitle = useMemo(() => {
43
43
  const name = account.alianName || ''
44
- if (name.length > 20) {
45
- return name.slice(0, 10) + '...'
44
+ if (name.length > MAX_ALIAS_NAME_LENGTH) {
45
+ return name.slice(0, MAX_ALIAS_NAME_LENGTH) + '...'
46
46
  }
47
47
  return name
48
48
  }, [account.alianName])
49
49
 
50
50
  const onInputChange = (e: { target: { value: string } } | string) => {
51
51
  const value = typeof e === 'string' ? e : e.target.value
52
- if (value.length <= 20) {
52
+ if (value.length <= MAX_ALIAS_NAME_LENGTH) {
53
53
  setAlianName(value)
54
54
  }
55
55
  }
@@ -1,5 +1,7 @@
1
1
  import { useMemo, useState } from 'react'
2
2
 
3
+ import { MAX_ALIAS_NAME_LENGTH } from '@unisat/wallet-shared'
4
+
3
5
  import { keyringsActions, useAppDispatch, useI18n, useNavigation, useWallet } from '..'
4
6
  export function useEditWalletNameScreenLogic() {
5
7
  const nav = useNavigation()
@@ -33,15 +35,15 @@ export function useEditWalletNameScreenLogic() {
33
35
  }, [alianName])
34
36
 
35
37
  const truncatedTitle = useMemo(() => {
36
- if (keyring.alianName && keyring.alianName.length > 20) {
37
- return keyring.alianName.slice(0, 20) + '...'
38
+ if (keyring.alianName && keyring.alianName.length > MAX_ALIAS_NAME_LENGTH) {
39
+ return keyring.alianName.slice(0, MAX_ALIAS_NAME_LENGTH) + '...'
38
40
  }
39
41
  return keyring.alianName || ''
40
42
  }, [keyring.alianName])
41
43
 
42
44
  const onInputChange = (e: { target: { value: string } } | string) => {
43
45
  const value = typeof e === 'string' ? e : e.target.value
44
- if (value.length <= 20) {
46
+ if (value.length <= MAX_ALIAS_NAME_LENGTH) {
45
47
  setAlianName(value)
46
48
  }
47
49
  }
@@ -1,7 +1,7 @@
1
1
  import { Inscription } from '@unisat/wallet-shared'
2
2
  import { useCallback, useEffect, useState } from 'react'
3
3
  import { useI18n, useNavigation, useWallet } from 'src/context'
4
- import { useCurrentAccount, useResetTxState } from 'src/hooks'
4
+ import { useCurrentAccount, useCurrentAccountCapabilities, useResetTxState } from 'src/hooks'
5
5
 
6
6
  const HIGH_BALANCE = 10000
7
7
 
@@ -19,6 +19,7 @@ export function useOrdinalsInscriptionScreenLogic() {
19
19
  const [isInitialLoading, setIsInitialLoading] = useState(!props.inscription)
20
20
 
21
21
  const currentAccount = useCurrentAccount()
22
+ const accountCapabilities = useCurrentAccountCapabilities()
22
23
 
23
24
  const resetTxState = useResetTxState()
24
25
 
@@ -100,7 +101,7 @@ export function useOrdinalsInscriptionScreenLogic() {
100
101
 
101
102
  const isUnconfirmed = inscription ? inscription.timestamp == 0 : false
102
103
 
103
- const withSend = inscription ? currentAccount.address === inscription.address : false
104
+ const withSend = inscription ? accountCapabilities.canCreateSigningRequest && currentAccount.address === inscription.address : false
104
105
 
105
106
  const children = inscription ? inscription.children || [] : []
106
107
  const parents = inscription ? inscription.parents || [] : []