@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
@@ -1,4 +1,6 @@
1
- import { createContext, ReactNode, useContext } from 'react'
1
+ import React, { ReactNode, useContext } from 'react'
2
+
3
+ import { BabylonConfigV2 } from '@unisat/babylon-service/types'
2
4
 
3
5
  import {
4
6
  Account,
@@ -6,12 +8,14 @@ import {
6
8
  AddressCAT20TokenSummary,
7
9
  AddressCAT20UtxoSummary,
8
10
  AddressCAT721CollectionSummary,
11
+ AddressFlagType,
9
12
  AddressRunesTokenSummary,
10
13
  AddressSummary,
11
14
  AddressTokenSummary,
12
15
  AlkanesBalance,
13
16
  AlkanesCollection,
14
17
  AlkanesInfo,
18
+ Announcement,
15
19
  AppInfo,
16
20
  AppSummary,
17
21
  BabylonAddressSummary,
@@ -23,32 +27,37 @@ import {
23
27
  CAT20MergeOrder,
24
28
  CAT721Balance,
25
29
  CoinPrice,
30
+ ConnectedSite,
26
31
  CosmosBalance,
27
32
  CosmosSignDataType,
28
33
  DecodedPsbt,
34
+ DummyTxType,
35
+ LocalPsbtSummary,
29
36
  FeeSummary,
30
37
  InscribeOrder,
31
38
  Inscription,
32
39
  InscriptionSummary,
40
+ RateUsStatus,
33
41
  RuneBalance,
42
+ SignedData,
43
+ SignedMessage,
34
44
  SignPsbtOptions,
45
+ StoredNotification,
35
46
  TickPriceItem,
36
47
  TokenBalance,
37
48
  TokenTransfer,
49
+ ToSignData,
50
+ ToSignInput,
51
+ ToSignMessage,
38
52
  TxHistoryItem,
39
- UserToSignInput,
53
+ UnspentOutput,
40
54
  UTXO,
41
55
  UTXO_Detail,
42
56
  VersionDetail,
43
57
  WalletConfig,
44
58
  WalletKeyring,
45
59
  WebsiteResult,
46
- ToSignInput,
47
- UnspentOutput,
48
- AddressFlagType,
49
- ConnectedSite,
50
60
  } from '@unisat/wallet-shared'
51
- import { BabylonConfigV2 } from '@unisat/babylon-service/types'
52
61
  import { AddressType, ChainType, NetworkType } from '@unisat/wallet-types'
53
62
 
54
63
  interface ContactBookItem {
@@ -65,7 +74,13 @@ export interface WalletController {
65
74
  openapi: {
66
75
  [key: string]: (...params: any) => Promise<any>
67
76
  }
77
+ // for development use only
78
+ requestMethod: (...params: any) => Promise<any>
68
79
 
80
+ setBackgroundInited(value: boolean): Promise<void>
81
+ getBackgroundInited(): Promise<boolean>
82
+
83
+ getDesc: () => string
69
84
  boot(password: string): Promise<void>
70
85
  isBooted(): Promise<boolean>
71
86
 
@@ -75,7 +90,7 @@ export interface WalletController {
75
90
 
76
91
  hasVault(): Promise<boolean>
77
92
 
78
- verifyPassword(password: string): Promise<void>
93
+ verifyPassword(password: string): Promise<boolean>
79
94
  changePassword: (password: string, newPassword: string) => Promise<void>
80
95
 
81
96
  unlock(password: string): Promise<void>
@@ -143,7 +158,8 @@ export interface WalletController {
143
158
  hdPath: string,
144
159
  passphrase: string,
145
160
  addressType: AddressType,
146
- accountCount: number
161
+ accountCount: number,
162
+ accountIndexDerivation?: boolean
147
163
  ): Promise<{ address: string; type: string }[]>
148
164
  createKeyringWithKeystone(
149
165
  urType: string,
@@ -186,8 +202,26 @@ export interface WalletController {
186
202
  hdPath: string,
187
203
  passphrase: string,
188
204
  addressType: AddressType,
189
- accountCount?: number
205
+ accountCount?: number,
206
+ accountIndexDerivation?: boolean
207
+ ): Promise<WalletKeyring>
208
+
209
+ createTmpKeyringWithMnemonics2(
210
+ mnemonic: string,
211
+ passphrase: string,
212
+ hdPaths: string[],
213
+ addressTypes: AddressType[]
214
+ ): Promise<WalletKeyring[]>
215
+
216
+ createTmpKeyringWithMnemonicsScan(
217
+ mnemonic: string,
218
+ hdPath: string,
219
+ passphrase: string,
220
+ addressType: AddressType,
221
+ accountCount: number,
222
+ accountIndexDerivation?: boolean
190
223
  ): Promise<WalletKeyring>
224
+
191
225
  removeKeyring(keyring: WalletKeyring): Promise<WalletKeyring>
192
226
  deriveNewAccountFromMnemonic(keyring: WalletKeyring, alianName?: string): Promise<string[]>
193
227
  getAccountsCount(): Promise<number>
@@ -200,74 +234,46 @@ export interface WalletController {
200
234
 
201
235
  getCurrentKeyringAccounts(): Promise<Account[]>
202
236
 
203
- signPsbtWithHex(
204
- psbtHex: string,
205
- toSignInputs: ToSignInput[],
206
- autoFinalized: boolean
207
- ): Promise<string>
237
+ signPsbtV2(toSignData: ToSignData): Promise<SignedData>
238
+
239
+ signMessage(params: ToSignMessage): Promise<SignedMessage>
208
240
 
209
- sendBTC(data: {
241
+ createSendBTCPsbt(data: {
210
242
  to: string
211
243
  amount: number
212
244
  btcUtxos: UnspentOutput[]
213
245
  feeRate: number
214
- enableRBF: boolean
215
246
  memo?: string
216
247
  memos?: string[]
217
- }): Promise<{
218
- psbtHex: string
219
- rawtx: string
220
- fee: number
221
- }>
248
+ }): Promise<ToSignData>
222
249
 
223
- sendAllBTC(data: {
250
+ createSendAllBTCPsbt(data: {
224
251
  to: string
225
252
  btcUtxos: UnspentOutput[]
226
253
  feeRate: number
227
- enableRBF: boolean
228
- }): Promise<{
229
- psbtHex: string
230
- rawtx: string
231
- fee: number
232
- }>
254
+ }): Promise<ToSignData>
233
255
 
234
- sendOrdinalsInscription(data: {
256
+ createSendInscriptionPsbt(data: {
235
257
  to: string
236
258
  inscriptionId: string
237
259
  feeRate: number
238
260
  outputValue?: number
239
- enableRBF: boolean
240
261
  btcUtxos: UnspentOutput[]
241
- }): Promise<{
242
- psbtHex: string
243
- rawtx: string
244
- fee: number
245
- }>
262
+ }): Promise<ToSignData>
246
263
 
247
- sendOrdinalsInscriptions(data: {
264
+ createSendMultipleInscriptionsPsbt(data: {
248
265
  to: string
249
266
  inscriptionIds: string[]
250
267
  feeRate: number
251
- enableRBF: boolean
252
268
  btcUtxos: UnspentOutput[]
253
- }): Promise<{
254
- psbtHex: string
255
- rawtx: string
256
- fee: number
257
- }>
269
+ }): Promise<ToSignData>
258
270
 
259
- splitOrdinalsInscription(data: {
271
+ createSplitInscriptionPsbt(data: {
260
272
  inscriptionId: string
261
273
  feeRate: number
262
274
  outputValue: number
263
- enableRBF: boolean
264
275
  btcUtxos: UnspentOutput[]
265
- }): Promise<{
266
- psbtHex: string
267
- rawtx: string
268
- fee: number
269
- splitedCount: number
270
- }>
276
+ }): Promise<ToSignData>
271
277
 
272
278
  pushTx(rawtx: string): Promise<string>
273
279
 
@@ -287,9 +293,11 @@ export interface WalletController {
287
293
  getConnectedSites(): Promise<ConnectedSite[]>
288
294
  removeConnectedSite(origin: string): Promise<void>
289
295
  getCurrentConnectedSite(id: string): Promise<ConnectedSite>
296
+ updateConnectSite(origin: string, data: Partial<ConnectedSite>): Promise<void>
290
297
 
291
298
  getCurrentKeyring(): Promise<WalletKeyring>
292
299
  getKeyrings(): Promise<WalletKeyring[]>
300
+ getTotalKeyringCount(): Promise<number>
293
301
  changeKeyring(keyring: WalletKeyring, accountIndex?: number): Promise<void>
294
302
  getAllAddresses(keyring: WalletKeyring, index: number): Promise<string[]>
295
303
 
@@ -298,6 +306,7 @@ export interface WalletController {
298
306
 
299
307
  setAccountAlianName(account: Account, name: string): Promise<Account>
300
308
  getFeeSummary(): Promise<FeeSummary>
309
+ getLowFeeSummary(): Promise<FeeSummary>
301
310
  getCoinPrice(): Promise<CoinPrice>
302
311
  getBrc20sPrice(ticks: string[]): Promise<{ [tick: string]: TickPriceItem }>
303
312
  getRunesPrice(ticks: string[]): Promise<{ [tick: string]: TickPriceItem }>
@@ -320,6 +329,7 @@ export interface WalletController {
320
329
  getInscribeResult(orderId: string): Promise<TokenTransfer>
321
330
 
322
331
  decodePsbt(psbtHex: string, website: string): Promise<DecodedPsbt>
332
+ analyzeLocalPsbts(toSignDatas: ToSignData[]): Promise<LocalPsbtSummary>
323
333
 
324
334
  decodeContracts(contracts: any[], account: any): Promise<any[]>
325
335
 
@@ -429,20 +439,15 @@ export interface WalletController {
429
439
 
430
440
  getAddressRunesTokenSummary(address: string, runeid: string): Promise<AddressRunesTokenSummary>
431
441
 
432
- sendRunes(data: {
442
+ createSendRunesPsbt(data: {
433
443
  to: string
434
444
  runeid: string
435
445
  runeAmount: string
436
446
  feeRate: number
437
- enableRBF: boolean
438
447
  btcUtxos?: UnspentOutput[]
439
448
  assetUtxos?: UnspentOutput[]
440
449
  outputValue?: number
441
- }): Promise<{
442
- psbtHex: string
443
- rawtx: string
444
- fee: number
445
- }>
450
+ }): Promise<ToSignData>
446
451
 
447
452
  setAutoLockTimeId(timeId: number): Promise<void>
448
453
  getAutoLockTimeId(): Promise<number>
@@ -475,18 +480,16 @@ export interface WalletController {
475
480
  tokenId: string,
476
481
  tokenAmount: string,
477
482
  feeRate: number
478
- ): Promise<{ id: string; commitTx: string; toSignInputs: UserToSignInput[]; feeRate: number }>
483
+ ): Promise<{ id: string; feeRate: number; toSignData: ToSignData }>
479
484
  transferCAT20Step2(
480
485
  version: 'v1' | 'v2',
481
486
  transferId: string,
482
- commitTx: string,
483
- toSignInputs: UserToSignInput[]
484
- ): Promise<{ revealTx: string; toSignInputs: UserToSignInput[] }>
487
+ psbtHex: string
488
+ ): Promise<{ toSignData: ToSignData }>
485
489
  transferCAT20Step3(
486
490
  version: 'v1' | 'v2',
487
491
  transferId: string,
488
- revealTx: string,
489
- toSignInputs: UserToSignInput[]
492
+ psbtHex: string
490
493
  ): Promise<{ txid: string }>
491
494
 
492
495
  mergeCAT20Prepare(
@@ -498,7 +501,7 @@ export interface WalletController {
498
501
  transferCAT20Step1ByMerge(
499
502
  version: 'v1' | 'v2',
500
503
  mergeId: string
501
- ): Promise<{ id: string; commitTx: string; toSignInputs: UserToSignInput[]; feeRate: number }>
504
+ ): Promise<{ id: string; feeRate: number; toSignData: ToSignData }>
502
505
  getMergeCAT20Status(version: 'v1' | 'v2', mergeId: string): Promise<any>
503
506
 
504
507
  getAppList(): Promise<{ tab: string; items: AppInfo[] }[]>
@@ -524,18 +527,16 @@ export interface WalletController {
524
527
  collectionId: string,
525
528
  localId: string,
526
529
  feeRate: number
527
- ): Promise<{ id: string; commitTx: string; toSignInputs: UserToSignInput[]; feeRate: number }>
530
+ ): Promise<{ id: string; feeRate: number; toSignData: ToSignData }>
528
531
  transferCAT721Step2(
529
532
  version: 'v1' | 'v2',
530
533
  transferId: string,
531
- commitTx: string,
532
- toSignInputs: UserToSignInput[]
533
- ): Promise<{ revealTx: string; toSignInputs: UserToSignInput[] }>
534
+ psbtHex: string
535
+ ): Promise<{ toSignData: ToSignData }>
534
536
  transferCAT721Step3(
535
537
  version: 'v1' | 'v2',
536
538
  transferId: string,
537
- revealTx: string,
538
- toSignInputs: UserToSignInput[]
539
+ psbtHex: string
539
540
  ): Promise<{ txid: string }>
540
541
 
541
542
  getBuyCoinChannelList(coin: string): Promise<BtcChannelItem[]>
@@ -593,23 +594,16 @@ export interface WalletController {
593
594
  feeRate: number
594
595
  }): Promise<{
595
596
  orderId: string
596
- psbtHex: string
597
- toSignInputs: UserToSignInput[]
597
+ toSignData: ToSignData
598
598
  }>
599
599
 
600
- singleStepTransferBRC20Step2(params: {
601
- orderId: string
602
- commitTx: string
603
- toSignInputs: UserToSignInput[]
604
- }): Promise<{
605
- psbtHex: string
606
- toSignInputs: UserToSignInput[]
600
+ singleStepTransferBRC20Step2(params: { orderId: string; commitTx: string }): Promise<{
601
+ toSignData: ToSignData
607
602
  }>
608
603
 
609
604
  singleStepTransferBRC20Step3(params: {
610
605
  orderId: string
611
606
  revealTx: string
612
- toSignInputs: UserToSignInput[]
613
607
  }): Promise<{ txid: string }>
614
608
 
615
609
  setLastActiveTime(): void
@@ -617,14 +611,10 @@ export interface WalletController {
617
611
  getOpenInSidePanel(): Promise<boolean>
618
612
  setOpenInSidePanel(openInSidePanel: boolean): Promise<void>
619
613
 
620
- sendCoinBypassHeadOffsets(
614
+ createSendBTCOffsetPsbt(
621
615
  tos: { address: string; satoshis: number }[],
622
616
  feeRate: number
623
- ): Promise<{
624
- psbtHex: string
625
- rawtx: string
626
- fee: number
627
- }>
617
+ ): Promise<ToSignData>
628
618
 
629
619
  getAlkanesList(
630
620
  address: string,
@@ -640,30 +630,13 @@ export interface WalletController {
640
630
  fetchAvailable: boolean
641
631
  ): Promise<AddressAlkanesTokenSummary>
642
632
 
643
- createAlkanesSendTx(params: {
644
- userAddress: string
645
- userPubkey: string
646
- receiver: string
647
- alkaneid: string
648
- amount: string
649
- feeRate: number
650
- }): Promise<{
651
- psbtHex: string
652
- toSignInputs: UserToSignInput[]
653
- }>
654
-
655
- signAlkanesSendTx(params: {
656
- commitTx: string
657
- toSignInputs: ToSignInput[]
658
- }): Promise<{ txid: string }>
659
-
660
- sendAlkanes(params: {
633
+ createSendAlkanesPsbt(params: {
661
634
  to: string
662
635
  alkaneid: string
663
636
  amount: string
664
637
  feeRate: number
665
- enableRBF: boolean
666
- }): Promise<string>
638
+ type: 'ft' | 'nft'
639
+ }): Promise<ToSignData>
667
640
 
668
641
  getAlkanesCollectionList(
669
642
  address: string,
@@ -678,9 +651,47 @@ export interface WalletController {
678
651
  ): Promise<{ currentPage: number; pageSize: number; list: AlkanesInfo[]; total: number }>
679
652
 
680
653
  getBRC20RecentHistory(address: string, ticker: string): Promise<BRC20HistoryItem[]>
654
+
655
+ resetAllData(): Promise<void>
656
+
657
+ getGuideReaded(): Promise<boolean>
658
+ setGuideReaded(): Promise<void>
659
+
660
+ getRateUsStatus(): Promise<RateUsStatus>
661
+
662
+ setHasRated(hasRated: boolean): Promise<void>
663
+ setRatePromptDismissedAt(timestamp: number | null): Promise<void>
664
+ setHasShownSecondPrompt(hasShown: boolean): Promise<void>
665
+ resetRateUsStatus(): Promise<void>
666
+ getAnnouncements(
667
+ cursor: number,
668
+ size: number
669
+ ): Promise<{
670
+ hasMore: boolean
671
+ list: Announcement[]
672
+ }>
673
+
674
+ getNotifications(): Promise<StoredNotification[]>
675
+ readNotification(id: string): Promise<void>
676
+ readAllNotifications(): Promise<void>
677
+ deleteNotification(id: string): Promise<void>
678
+ getNotificationUnreadCount(): Promise<number>
679
+
680
+ getAcceptLowFeeMode(): Promise<boolean>
681
+ setAcceptLowFeeMode(accept: boolean): Promise<void>
682
+
683
+ createTmpKeyringWithPublicKey(publicKey: string, addressType: AddressType): Promise<WalletKeyring>
684
+
685
+ createKeyringWithPublicKey(data: string, addressType: AddressType): Promise<void>
686
+
687
+ createTmpKeyringWithAddress(address: string): Promise<WalletKeyring>
688
+
689
+ createKeyringWithAddress(address: string): Promise<void>
690
+
691
+ createDummyPsbt(params: { txType: DummyTxType }): Promise<ToSignData>
681
692
  }
682
693
 
683
- const WalletContext = createContext<{
694
+ const WalletContext = React.createContext<{
684
695
  wallet: WalletController
685
696
  } | null>(null)
686
697
 
@@ -1,3 +1,18 @@
1
- export { I18nProvider } from './I18nContext'
1
+ export { ApprovalContext, useApproval, type ApprovalContextType } from './ApprovalContext'
2
+ export { DeviceContext, useDevice, type DeviceContextType } from './DeviceContext'
3
+ export { I18nContext, useI18n, type I18nContextType } from './I18nContext'
4
+ export {
5
+ NavigationContext,
6
+ useNavigation,
7
+ type NavigationContextType,
8
+ type RouteTypes,
9
+ } from './NavigationContext'
10
+ export { PriceProvider, usePrice } from './PriceContext'
11
+ export {
12
+ createStorageProvider,
13
+ StorageContext,
14
+ useStorage,
15
+ type StorageContextType,
16
+ } from './StorageContext'
17
+ export { ToolsContext, useTools, type ToolsContextType } from './ToolsContext'
2
18
  export { useWallet, WalletProvider } from './WalletContext'
3
- export { usePrice, PriceProvider } from './PriceContext'
@@ -2,16 +2,16 @@ import { useCallback } from 'react'
2
2
 
3
3
  import { Account } from '@unisat/wallet-shared'
4
4
 
5
- import { AddressType } from '@unisat/wallet-types'
6
5
  import { KeyringType } from '@unisat/keyring-service/types'
6
+ import { AddressType, ChainType } from '@unisat/wallet-types'
7
7
 
8
8
  import { AppState } from '..'
9
- import { useAppDispatch, useAppSelector } from './base'
10
- import { useCurrentKeyring } from './keyrings'
9
+ import { useWallet } from '../context/WalletContext'
10
+ import { accountActions } from '../reducers/accounts'
11
11
  import { keyringsActions } from '../reducers/keyrings'
12
12
  import { settingsActions } from '../reducers/settings'
13
- import { accountActions } from '../reducers/accounts'
14
- import { useWallet } from '../context/WalletContext'
13
+ import { useAppDispatch, useAppSelector } from './base'
14
+ import { useCurrentKeyring } from './keyrings'
15
15
 
16
16
  export function useAccountsState(): AppState['accounts'] {
17
17
  return useAppSelector(state => state.accounts)
@@ -40,6 +40,7 @@ export function useAccountBalance() {
40
40
  availableBalance: 0,
41
41
  unavailableBalance: 0,
42
42
  totalBalance: 0,
43
+ chainType: ChainType.BITCOIN_MAINNET,
43
44
  }
44
45
  )
45
46
  }
@@ -210,6 +211,7 @@ export function useFetchBalanceCallback() {
210
211
  accountActions['setBalanceV2']!({
211
212
  address: currentAccount.address,
212
213
  balance: balanceV2,
214
+ chainType: balanceV2.chainType,
213
215
  })
214
216
  )
215
217
  }, [dispatch, wallet, currentAccount, balance])
@@ -244,3 +246,7 @@ export function useIsKeystoneWallet() {
244
246
  const currentKeyring = useCurrentKeyring()
245
247
  return currentKeyring.type === KeyringType.KeystoneKeyring
246
248
  }
249
+ export function useModelPopover() {
250
+ const modelState = useAccountsState()
251
+ return modelState.molelsPopover
252
+ }
@@ -0,0 +1,11 @@
1
+ import { AppState } from '..'
2
+ import { useAppSelector } from '../hooks'
3
+
4
+ export function useBrowserState(): AppState['browser'] {
5
+ return useAppSelector(state => state.browser)
6
+ }
7
+
8
+ export function useWalletTabScreenState() {
9
+ const state = useBrowserState()
10
+ return state.walletTabScreen
11
+ }