@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.
- package/lib/index.d.mts +87 -18
- package/lib/index.d.ts +87 -18
- package/lib/index.js +516 -175
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +514 -178
- package/lib/index.mjs.map +1 -1
- package/lib/types/index.d.mts +6 -2
- package/lib/types/index.d.ts +6 -2
- 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/package.json +4 -4
- package/src/context/NavigationContext.tsx +1 -0
- package/src/context/WalletContext.tsx +56 -23
- package/src/hooks/accounts.ts +7 -2
- package/src/hooks/settings.ts +10 -0
- package/src/hooks/transactions.ts +75 -10
- package/src/hooks/ui.ts +83 -63
- package/src/reducers/accounts.ts +3 -0
- package/src/reducers/ui.ts +21 -0
- package/src/types/ui.ts +6 -1
- package/src/ui-hooks/useAddressTypeScreenLogic.ts +22 -8
- package/src/ui-hooks/useAlkanesNFTScreenLogic.ts +3 -2
- package/src/ui-hooks/useAlkanesTokenScreenLogic.ts +12 -2
- package/src/ui-hooks/useBRC20InscribeTransferLogic.ts +30 -10
- package/src/ui-hooks/useBRC20ListLogic.ts +6 -2
- package/src/ui-hooks/useBRC20ProgListLogic.ts +7 -3
- package/src/ui-hooks/useBRC20SendScreenLogic.ts +19 -6
- package/src/ui-hooks/useBRC20TokenScreenLogic.ts +48 -25
- package/src/ui-hooks/useCAT20TokenScreenLogic.ts +16 -2
- package/src/ui-hooks/useCAT721NFTScreenLogic.ts +3 -1
- package/src/ui-hooks/useEditAccountNameScreenLogic.ts +4 -4
- package/src/ui-hooks/useEditWalletNameScreenLogic.ts +5 -3
- package/src/ui-hooks/useOrdinalsInscriptionScreenLogic.ts +3 -2
- package/src/ui-hooks/useRunesTokenScreenLogic.ts +11 -2
- package/src/ui-hooks/useSendAlkanesNFTScreenLogic.ts +24 -2
- package/src/ui-hooks/useSendAlkanesScreenLogic.ts +17 -1
- package/src/ui-hooks/useSendOrdinalsInscriptionScreenLogic.ts +17 -5
- package/src/ui-hooks/useSendRunesScreenLogic.ts +18 -1
- package/src/ui-hooks/useSettingsTabScreenLogic.ts +18 -3
- package/src/ui-hooks/useSignMessageLogic.ts +37 -16
- package/src/ui-hooks/useSignPsbtLogic.ts +31 -15
- package/src/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.ts +15 -1
- package/src/ui-hooks/useTxCreateScreenLogic.ts +17 -1
|
@@ -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(
|
|
@@ -35,6 +36,7 @@ export function usePrepareSendBTCCallback() {
|
|
|
35
36
|
memo,
|
|
36
37
|
memos,
|
|
37
38
|
disableAutoAdjust,
|
|
39
|
+
enableRBF,
|
|
38
40
|
}: {
|
|
39
41
|
toAddressInfo: ToAddressInfo
|
|
40
42
|
toAmount: number
|
|
@@ -42,7 +44,11 @@ export function usePrepareSendBTCCallback() {
|
|
|
42
44
|
memo?: string
|
|
43
45
|
memos?: string[]
|
|
44
46
|
disableAutoAdjust?: boolean
|
|
47
|
+
enableRBF?: boolean
|
|
45
48
|
}) => {
|
|
49
|
+
if (!accountCapabilities.canCreateSigningRequest) {
|
|
50
|
+
throw new Error(t('not_supported'))
|
|
51
|
+
}
|
|
46
52
|
let _utxos: UnspentOutput[] = utxos
|
|
47
53
|
if (_utxos.length === 0) {
|
|
48
54
|
_utxos = await fetchUtxos()
|
|
@@ -65,6 +71,7 @@ export function usePrepareSendBTCCallback() {
|
|
|
65
71
|
to: toAddressInfo.address,
|
|
66
72
|
btcUtxos: _utxos,
|
|
67
73
|
feeRate,
|
|
74
|
+
enableRBF,
|
|
68
75
|
})
|
|
69
76
|
} else {
|
|
70
77
|
res = await wallet.createSendBTCPsbt({
|
|
@@ -72,6 +79,7 @@ export function usePrepareSendBTCCallback() {
|
|
|
72
79
|
amount: toAmount,
|
|
73
80
|
btcUtxos: _utxos,
|
|
74
81
|
feeRate,
|
|
82
|
+
enableRBF,
|
|
75
83
|
memo: memo!,
|
|
76
84
|
memos: memos!,
|
|
77
85
|
})
|
|
@@ -79,23 +87,30 @@ export function usePrepareSendBTCCallback() {
|
|
|
79
87
|
|
|
80
88
|
return res
|
|
81
89
|
},
|
|
82
|
-
[dispatch, wallet, fromAddress, utxos, fetchUtxos]
|
|
90
|
+
[dispatch, wallet, fromAddress, utxos, fetchUtxos, accountCapabilities.canCreateSigningRequest, t]
|
|
83
91
|
)
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
export function usePrepareSendBypassHeadOffsetsCallback() {
|
|
87
95
|
const dispatch = useAppDispatch()
|
|
88
96
|
const wallet = useWallet()
|
|
97
|
+
const accountCapabilities = useCurrentAccountCapabilities()
|
|
98
|
+
const { t } = useI18n()
|
|
89
99
|
return useCallback(
|
|
90
100
|
async ({
|
|
91
101
|
toAddressInfo,
|
|
92
102
|
toAmount,
|
|
93
103
|
feeRate,
|
|
104
|
+
enableRBF,
|
|
94
105
|
}: {
|
|
95
106
|
toAddressInfo: ToAddressInfo
|
|
96
107
|
toAmount: number
|
|
97
108
|
feeRate: number
|
|
109
|
+
enableRBF?: boolean
|
|
98
110
|
}) => {
|
|
111
|
+
if (!accountCapabilities.canCreateSigningRequest) {
|
|
112
|
+
throw new Error(t('not_supported'))
|
|
113
|
+
}
|
|
99
114
|
const res = await wallet.createSendBTCOffsetPsbt(
|
|
100
115
|
[
|
|
101
116
|
{
|
|
@@ -103,11 +118,12 @@ export function usePrepareSendBypassHeadOffsetsCallback() {
|
|
|
103
118
|
satoshis: toAmount,
|
|
104
119
|
},
|
|
105
120
|
],
|
|
106
|
-
feeRate
|
|
121
|
+
feeRate,
|
|
122
|
+
enableRBF
|
|
107
123
|
)
|
|
108
124
|
return res
|
|
109
125
|
},
|
|
110
|
-
[dispatch, wallet]
|
|
126
|
+
[dispatch, wallet, accountCapabilities.canCreateSigningRequest, t]
|
|
111
127
|
)
|
|
112
128
|
}
|
|
113
129
|
|
|
@@ -160,18 +176,25 @@ export function usePrepareSendOrdinalsInscriptionCallback() {
|
|
|
160
176
|
const fromAddress = useAccountAddress()
|
|
161
177
|
const utxos = useUtxos()
|
|
162
178
|
const fetchUtxos = useFetchUtxosCallback()
|
|
179
|
+
const accountCapabilities = useCurrentAccountCapabilities()
|
|
180
|
+
const { t } = useI18n()
|
|
163
181
|
return useCallback(
|
|
164
182
|
async ({
|
|
165
183
|
toAddressInfo,
|
|
166
184
|
inscriptionId,
|
|
167
185
|
feeRate,
|
|
168
186
|
outputValue,
|
|
187
|
+
enableRBF,
|
|
169
188
|
}: {
|
|
170
189
|
toAddressInfo: ToAddressInfo
|
|
171
190
|
inscriptionId: string
|
|
172
191
|
feeRate?: number
|
|
173
192
|
outputValue?: number
|
|
193
|
+
enableRBF?: boolean
|
|
174
194
|
}) => {
|
|
195
|
+
if (!accountCapabilities.canCreateSigningRequest) {
|
|
196
|
+
throw new Error(t('not_supported'))
|
|
197
|
+
}
|
|
175
198
|
if (!feeRate) {
|
|
176
199
|
const summary = await wallet.getFeeSummary()
|
|
177
200
|
feeRate = summary.list[1]!.feeRate
|
|
@@ -188,11 +211,12 @@ export function usePrepareSendOrdinalsInscriptionCallback() {
|
|
|
188
211
|
feeRate,
|
|
189
212
|
outputValue: outputValue!,
|
|
190
213
|
btcUtxos,
|
|
214
|
+
enableRBF,
|
|
191
215
|
})
|
|
192
216
|
|
|
193
217
|
return toSignData
|
|
194
218
|
},
|
|
195
|
-
[dispatch, wallet, fromAddress, utxos]
|
|
219
|
+
[dispatch, wallet, fromAddress, utxos, accountCapabilities.canCreateSigningRequest, t]
|
|
196
220
|
)
|
|
197
221
|
}
|
|
198
222
|
|
|
@@ -202,16 +226,23 @@ export function usePrepareSendOrdinalsInscriptionsCallback() {
|
|
|
202
226
|
const fromAddress = useAccountAddress()
|
|
203
227
|
const fetchUtxos = useFetchUtxosCallback()
|
|
204
228
|
const utxos = useUtxos()
|
|
229
|
+
const accountCapabilities = useCurrentAccountCapabilities()
|
|
230
|
+
const { t } = useI18n()
|
|
205
231
|
return useCallback(
|
|
206
232
|
async ({
|
|
207
233
|
toAddressInfo,
|
|
208
234
|
inscriptionIds,
|
|
209
235
|
feeRate,
|
|
236
|
+
enableRBF,
|
|
210
237
|
}: {
|
|
211
238
|
toAddressInfo: ToAddressInfo
|
|
212
239
|
inscriptionIds: string[]
|
|
213
240
|
feeRate?: number
|
|
241
|
+
enableRBF?: boolean
|
|
214
242
|
}) => {
|
|
243
|
+
if (!accountCapabilities.canCreateSigningRequest) {
|
|
244
|
+
throw new Error(t('not_supported'))
|
|
245
|
+
}
|
|
215
246
|
if (!feeRate) {
|
|
216
247
|
const summary = await wallet.getFeeSummary()
|
|
217
248
|
feeRate = summary.list[1]!.feeRate
|
|
@@ -226,11 +257,12 @@ export function usePrepareSendOrdinalsInscriptionsCallback() {
|
|
|
226
257
|
inscriptionIds,
|
|
227
258
|
feeRate,
|
|
228
259
|
btcUtxos,
|
|
260
|
+
enableRBF,
|
|
229
261
|
})
|
|
230
262
|
|
|
231
263
|
return res
|
|
232
264
|
},
|
|
233
|
-
[dispatch, wallet, fromAddress, utxos]
|
|
265
|
+
[dispatch, wallet, fromAddress, utxos, accountCapabilities.canCreateSigningRequest, t]
|
|
234
266
|
)
|
|
235
267
|
}
|
|
236
268
|
|
|
@@ -241,16 +273,23 @@ export function useCreateSplitTxCallback() {
|
|
|
241
273
|
const utxos = useUtxos()
|
|
242
274
|
const fetchUtxos = useFetchUtxosCallback()
|
|
243
275
|
const account = useCurrentAccount()
|
|
276
|
+
const accountCapabilities = useCurrentAccountCapabilities()
|
|
277
|
+
const { t } = useI18n()
|
|
244
278
|
return useCallback(
|
|
245
279
|
async ({
|
|
246
280
|
inscriptionId,
|
|
247
281
|
feeRate,
|
|
248
282
|
outputValue,
|
|
283
|
+
enableRBF,
|
|
249
284
|
}: {
|
|
250
285
|
inscriptionId: string
|
|
251
286
|
feeRate: number
|
|
252
287
|
outputValue: number
|
|
288
|
+
enableRBF?: boolean
|
|
253
289
|
}) => {
|
|
290
|
+
if (!accountCapabilities.canCreateSigningRequest) {
|
|
291
|
+
throw new Error(t('not_supported'))
|
|
292
|
+
}
|
|
254
293
|
let btcUtxos = utxos
|
|
255
294
|
if (btcUtxos.length === 0) {
|
|
256
295
|
btcUtxos = await fetchUtxos()
|
|
@@ -261,11 +300,12 @@ export function useCreateSplitTxCallback() {
|
|
|
261
300
|
feeRate,
|
|
262
301
|
outputValue,
|
|
263
302
|
btcUtxos,
|
|
303
|
+
enableRBF,
|
|
264
304
|
})
|
|
265
305
|
|
|
266
306
|
return res
|
|
267
307
|
},
|
|
268
|
-
[dispatch, wallet, fromAddress, utxos]
|
|
308
|
+
[dispatch, wallet, fromAddress, utxos, accountCapabilities.canCreateSigningRequest, t]
|
|
269
309
|
)
|
|
270
310
|
}
|
|
271
311
|
|
|
@@ -378,6 +418,8 @@ export function usePrepareSendRunesCallback() {
|
|
|
378
418
|
const assetUtxosRunes = useAssetUtxosRunes()
|
|
379
419
|
const fetchAssetUtxosRunes = useFetchAssetUtxosRunesCallback()
|
|
380
420
|
const account = useCurrentAccount()
|
|
421
|
+
const accountCapabilities = useCurrentAccountCapabilities()
|
|
422
|
+
const { t } = useI18n()
|
|
381
423
|
return useCallback(
|
|
382
424
|
async ({
|
|
383
425
|
toAddressInfo,
|
|
@@ -385,13 +427,18 @@ export function usePrepareSendRunesCallback() {
|
|
|
385
427
|
runeAmount,
|
|
386
428
|
outputValue,
|
|
387
429
|
feeRate,
|
|
430
|
+
enableRBF,
|
|
388
431
|
}: {
|
|
389
432
|
toAddressInfo: ToAddressInfo
|
|
390
433
|
runeid: string
|
|
391
434
|
runeAmount: string
|
|
392
435
|
outputValue?: number
|
|
393
436
|
feeRate: number
|
|
437
|
+
enableRBF?: boolean
|
|
394
438
|
}) => {
|
|
439
|
+
if (!accountCapabilities.canCreateSigningRequest) {
|
|
440
|
+
throw new Error(t('not_supported'))
|
|
441
|
+
}
|
|
395
442
|
if (!feeRate) {
|
|
396
443
|
const summary = await wallet.getFeeSummary()
|
|
397
444
|
feeRate = summary.list[1]!.feeRate
|
|
@@ -415,11 +462,22 @@ export function usePrepareSendRunesCallback() {
|
|
|
415
462
|
feeRate,
|
|
416
463
|
btcUtxos,
|
|
417
464
|
assetUtxos,
|
|
465
|
+
enableRBF,
|
|
418
466
|
})
|
|
419
467
|
|
|
420
468
|
return toSignData
|
|
421
469
|
},
|
|
422
|
-
[
|
|
470
|
+
[
|
|
471
|
+
dispatch,
|
|
472
|
+
wallet,
|
|
473
|
+
fromAddress,
|
|
474
|
+
utxos,
|
|
475
|
+
assetUtxosRunes,
|
|
476
|
+
fetchAssetUtxosRunes,
|
|
477
|
+
account,
|
|
478
|
+
accountCapabilities.canCreateSigningRequest,
|
|
479
|
+
t,
|
|
480
|
+
]
|
|
423
481
|
)
|
|
424
482
|
}
|
|
425
483
|
|
|
@@ -431,23 +489,30 @@ export function useRunesTx() {
|
|
|
431
489
|
export function usePrepareSendAlkanesCallback() {
|
|
432
490
|
const wallet = useWallet()
|
|
433
491
|
const account = useCurrentAccount()
|
|
492
|
+
const accountCapabilities = useCurrentAccountCapabilities()
|
|
493
|
+
const { t } = useI18n()
|
|
434
494
|
const callback = useCallback(
|
|
435
495
|
async (
|
|
436
496
|
toAddressInfo: ToAddressInfo,
|
|
437
497
|
alkaneid: string,
|
|
438
498
|
amount: string,
|
|
439
499
|
feeRate: number,
|
|
440
|
-
type: 'ft' | 'nft'
|
|
500
|
+
type: 'ft' | 'nft',
|
|
501
|
+
enableRBF?: boolean
|
|
441
502
|
) => {
|
|
503
|
+
if (!accountCapabilities.canCreateSigningRequest) {
|
|
504
|
+
throw new Error(t('not_supported'))
|
|
505
|
+
}
|
|
442
506
|
return await wallet.createSendAlkanesPsbt({
|
|
443
507
|
to: toAddressInfo.address,
|
|
444
508
|
alkaneid,
|
|
445
509
|
amount,
|
|
446
510
|
feeRate,
|
|
447
511
|
type,
|
|
512
|
+
enableRBF,
|
|
448
513
|
})
|
|
449
514
|
},
|
|
450
|
-
[wallet, account]
|
|
515
|
+
[wallet, account, accountCapabilities.canCreateSigningRequest, t]
|
|
451
516
|
)
|
|
452
517
|
return callback
|
|
453
518
|
}
|
package/src/hooks/ui.ts
CHANGED
|
@@ -33,6 +33,11 @@ export function useAlkanesAssetTabKey() {
|
|
|
33
33
|
return uiState.alkanesAssetTabKey
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export function useMoreAssetTabKey() {
|
|
37
|
+
const uiState = useUIState()
|
|
38
|
+
return uiState.moreAssetTabKey
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
export function useUiTxCreateScreen() {
|
|
37
42
|
const uiState = useUIState()
|
|
38
43
|
return uiState.uiTxCreateScreen
|
|
@@ -40,20 +45,26 @@ export function useUiTxCreateScreen() {
|
|
|
40
45
|
|
|
41
46
|
export function useUpdateUiTxCreateScreen() {
|
|
42
47
|
const dispatch = useAppDispatch()
|
|
43
|
-
return (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
)
|
|
57
68
|
}
|
|
58
69
|
|
|
59
70
|
export function useFeeRateBar() {
|
|
@@ -63,36 +74,39 @@ export function useFeeRateBar() {
|
|
|
63
74
|
|
|
64
75
|
export function useUpdateFeeRateBar() {
|
|
65
76
|
const dispatch = useAppDispatch()
|
|
66
|
-
return (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
+
)
|
|
89
103
|
}
|
|
90
104
|
|
|
91
105
|
export function useResetFeeRateBar() {
|
|
92
106
|
const dispatch = useAppDispatch()
|
|
93
|
-
return () => {
|
|
107
|
+
return useCallback(() => {
|
|
94
108
|
dispatch((uiActions as any).resetFeeRateBar())
|
|
95
|
-
}
|
|
109
|
+
}, [dispatch])
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
export function useAddressInput() {
|
|
@@ -102,21 +116,24 @@ export function useAddressInput() {
|
|
|
102
116
|
|
|
103
117
|
export function useUpdateAddressInput() {
|
|
104
118
|
const dispatch = useAppDispatch()
|
|
105
|
-
return (
|
|
106
|
-
|
|
107
|
-
(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
)
|
|
113
130
|
}
|
|
114
131
|
|
|
115
132
|
export function useResetAddressInput() {
|
|
116
133
|
const dispatch = useAppDispatch()
|
|
117
|
-
return () => {
|
|
134
|
+
return useCallback(() => {
|
|
118
135
|
dispatch((uiActions as any).resetAddressInput())
|
|
119
|
-
}
|
|
136
|
+
}, [dispatch])
|
|
120
137
|
}
|
|
121
138
|
|
|
122
139
|
export function useAmountInput() {
|
|
@@ -126,35 +143,38 @@ export function useAmountInput() {
|
|
|
126
143
|
|
|
127
144
|
export function useUpdateAmountInput() {
|
|
128
145
|
const dispatch = useAppDispatch()
|
|
129
|
-
return (
|
|
130
|
-
|
|
131
|
-
(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
return useCallback(
|
|
147
|
+
({ amount }: { amount?: string }) => {
|
|
148
|
+
dispatch(
|
|
149
|
+
(uiActions as any).updateAmountInput({
|
|
150
|
+
amount,
|
|
151
|
+
})
|
|
152
|
+
)
|
|
153
|
+
},
|
|
154
|
+
[dispatch]
|
|
155
|
+
)
|
|
136
156
|
}
|
|
137
157
|
|
|
138
158
|
export function useResetAmountInput() {
|
|
139
159
|
const dispatch = useAppDispatch()
|
|
140
|
-
return () => {
|
|
160
|
+
return useCallback(() => {
|
|
141
161
|
dispatch((uiActions as any).resetAmountInput())
|
|
142
|
-
}
|
|
162
|
+
}, [dispatch])
|
|
143
163
|
}
|
|
144
164
|
|
|
145
165
|
export function useResetTxState() {
|
|
146
166
|
const dispatch = useAppDispatch()
|
|
147
|
-
return () => {
|
|
167
|
+
return useCallback(() => {
|
|
148
168
|
dispatch((uiActions as any).resetTxCreateScreen())
|
|
149
169
|
dispatch((uiActions as any).resetFeeRateBar())
|
|
150
|
-
}
|
|
170
|
+
}, [dispatch])
|
|
151
171
|
}
|
|
152
172
|
|
|
153
173
|
export function useResetUiTxCreateScreen() {
|
|
154
174
|
const dispatch = useAppDispatch()
|
|
155
|
-
return () => {
|
|
175
|
+
return useCallback(() => {
|
|
156
176
|
dispatch((uiActions as any).resetTxCreateScreen())
|
|
157
|
-
}
|
|
177
|
+
}, [dispatch])
|
|
158
178
|
}
|
|
159
179
|
|
|
160
180
|
export const useThrottle = (callback, delay, lastCallRef) => {
|
|
@@ -202,7 +222,7 @@ export function getSupportedAssets(chainType: ChainType, address: string) {
|
|
|
202
222
|
|
|
203
223
|
if (chainType === ChainType.BITCOIN_MAINNET || chainType === ChainType.BITCOIN_SIGNET) {
|
|
204
224
|
assets.alkanes = true
|
|
205
|
-
assetTabKeys.push(AssetTabKey.
|
|
225
|
+
assetTabKeys.push(AssetTabKey.MORE)
|
|
206
226
|
}
|
|
207
227
|
|
|
208
228
|
if (chainType === ChainType.BITCOIN_MAINNET || chainType === ChainType.BITCOIN_SIGNET) {
|
package/src/reducers/accounts.ts
CHANGED
|
@@ -183,6 +183,9 @@ const slice: Slice<AccountsState> = createSlice({
|
|
|
183
183
|
setAddressSummary(state, action: { payload: any }) {
|
|
184
184
|
state.addressSummary = action.payload
|
|
185
185
|
},
|
|
186
|
+
setModelPopover(state, action: { payload: MolelsPopover }) {
|
|
187
|
+
state.molelsPopover = action.payload
|
|
188
|
+
},
|
|
186
189
|
expireBalance(state) {
|
|
187
190
|
const balance = state.balanceMap[state.current.address]
|
|
188
191
|
if (balance) {
|
package/src/reducers/ui.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
AlkanesAssetTabKey,
|
|
7
7
|
AssetTabKey,
|
|
8
8
|
CATAssetTabKey,
|
|
9
|
+
MoreAssetTabKey,
|
|
9
10
|
NavigationSource,
|
|
10
11
|
OrdinalsAssetTabKey,
|
|
11
12
|
} from '../types'
|
|
@@ -23,6 +24,7 @@ export interface UIState {
|
|
|
23
24
|
ordinalsAssetTabKey: OrdinalsAssetTabKey
|
|
24
25
|
catAssetTabKey: CATAssetTabKey
|
|
25
26
|
alkanesAssetTabKey: AlkanesAssetTabKey
|
|
27
|
+
moreAssetTabKey: MoreAssetTabKey
|
|
26
28
|
uiTxCreateScreen: {
|
|
27
29
|
toInfo: {
|
|
28
30
|
address: string
|
|
@@ -30,6 +32,7 @@ export interface UIState {
|
|
|
30
32
|
inscription?: Inscription
|
|
31
33
|
}
|
|
32
34
|
inputAmount: string
|
|
35
|
+
enableRBF: boolean
|
|
33
36
|
}
|
|
34
37
|
addressInput: {
|
|
35
38
|
address: string
|
|
@@ -64,12 +67,14 @@ export const initialState: UIState = {
|
|
|
64
67
|
ordinalsAssetTabKey: OrdinalsAssetTabKey.ALL,
|
|
65
68
|
catAssetTabKey: CATAssetTabKey.CAT20,
|
|
66
69
|
alkanesAssetTabKey: AlkanesAssetTabKey.TOKEN,
|
|
70
|
+
moreAssetTabKey: MoreAssetTabKey.ALKANES_TOKEN,
|
|
67
71
|
uiTxCreateScreen: {
|
|
68
72
|
toInfo: {
|
|
69
73
|
address: '',
|
|
70
74
|
domain: '',
|
|
71
75
|
},
|
|
72
76
|
inputAmount: '',
|
|
77
|
+
enableRBF: true,
|
|
73
78
|
},
|
|
74
79
|
addressInput: {
|
|
75
80
|
address: '',
|
|
@@ -113,6 +118,7 @@ const slice: Slice<UIState> = createSlice({
|
|
|
113
118
|
ordinalsAssetTabKey?: OrdinalsAssetTabKey
|
|
114
119
|
catAssetTabKey?: CATAssetTabKey
|
|
115
120
|
alkanesAssetTabKey?: AlkanesAssetTabKey
|
|
121
|
+
moreAssetTabKey?: MoreAssetTabKey
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
) {
|
|
@@ -130,6 +136,9 @@ const slice: Slice<UIState> = createSlice({
|
|
|
130
136
|
if (payload.alkanesAssetTabKey !== undefined) {
|
|
131
137
|
state.alkanesAssetTabKey = payload.alkanesAssetTabKey
|
|
132
138
|
}
|
|
139
|
+
if (payload.moreAssetTabKey !== undefined) {
|
|
140
|
+
state.moreAssetTabKey = payload.moreAssetTabKey
|
|
141
|
+
}
|
|
133
142
|
return state
|
|
134
143
|
},
|
|
135
144
|
updateTxCreateScreen(
|
|
@@ -142,6 +151,7 @@ const slice: Slice<UIState> = createSlice({
|
|
|
142
151
|
inscription?: Inscription
|
|
143
152
|
}
|
|
144
153
|
inputAmount?: string
|
|
154
|
+
enableRBF?: boolean
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
157
|
) {
|
|
@@ -151,6 +161,9 @@ const slice: Slice<UIState> = createSlice({
|
|
|
151
161
|
if (action.payload.inputAmount !== undefined) {
|
|
152
162
|
state.uiTxCreateScreen.inputAmount = action.payload.inputAmount
|
|
153
163
|
}
|
|
164
|
+
if (action.payload.enableRBF !== undefined) {
|
|
165
|
+
state.uiTxCreateScreen.enableRBF = action.payload.enableRBF
|
|
166
|
+
}
|
|
154
167
|
|
|
155
168
|
state.uiTxCreateScreen = { ...state.uiTxCreateScreen }
|
|
156
169
|
},
|
|
@@ -274,8 +287,16 @@ const slice: Slice<UIState> = createSlice({
|
|
|
274
287
|
if (!state.alkanesAssetTabKey) {
|
|
275
288
|
state.alkanesAssetTabKey = AlkanesAssetTabKey.TOKEN
|
|
276
289
|
}
|
|
290
|
+
if (state.moreAssetTabKey === undefined) {
|
|
291
|
+
state.moreAssetTabKey = MoreAssetTabKey.ALKANES_TOKEN
|
|
292
|
+
}
|
|
293
|
+
if (state.assetTabKey === (4 as AssetTabKey)) {
|
|
294
|
+
state.assetTabKey = AssetTabKey.MORE
|
|
295
|
+
}
|
|
277
296
|
if (!state.uiTxCreateScreen) {
|
|
278
297
|
state.uiTxCreateScreen = initialState.uiTxCreateScreen
|
|
298
|
+
} else if (state.uiTxCreateScreen.enableRBF === undefined) {
|
|
299
|
+
state.uiTxCreateScreen.enableRBF = true
|
|
279
300
|
}
|
|
280
301
|
if (!state.feeRateBar) {
|
|
281
302
|
state.feeRateBar = initialState.feeRateBar
|
package/src/types/ui.ts
CHANGED
|
@@ -3,7 +3,7 @@ export enum AssetTabKey {
|
|
|
3
3
|
ATOMICALS = 1, // IGNORED
|
|
4
4
|
RUNES = 2,
|
|
5
5
|
CAT = 3,
|
|
6
|
-
|
|
6
|
+
MORE = 4,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export enum OrdinalsAssetTabKey {
|
|
@@ -24,6 +24,11 @@ export enum AlkanesAssetTabKey {
|
|
|
24
24
|
COLLECTION,
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export enum MoreAssetTabKey {
|
|
28
|
+
ALKANES_TOKEN,
|
|
29
|
+
ALKANES_COLLECTION,
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
export enum NavigationSource {
|
|
28
33
|
BACK,
|
|
29
34
|
NORMAL,
|
|
@@ -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
|
-
//
|
|
81
|
-
if (
|
|
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
|
-
}, [
|
|
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(
|
|
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
|
-
|
|
141
|
-
|
|
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
|
|