@unisat/wallet-state 1.0.5 → 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.
- package/LICENSE +0 -5
- package/lib/index.d.mts +2012 -200
- package/lib/index.d.ts +2012 -200
- package/lib/index.js +6951 -570
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +6754 -517
- package/lib/index.mjs.map +1 -1
- package/lib/types/index.d.mts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/package.json +19 -15
- package/src/.DS_Store +0 -0
- package/src/context/ApprovalContext.tsx +27 -0
- package/src/context/DeviceContext.tsx +36 -0
- package/src/context/I18nContext.tsx +14 -172
- package/src/context/NavigationContext.tsx +305 -0
- package/src/context/PriceContext.tsx +2 -2
- package/src/context/StorageContext.tsx +393 -0
- package/src/context/ToolsContext.tsx +50 -0
- package/src/context/WalletContext.tsx +119 -108
- package/src/context/index.ts +17 -2
- package/src/hooks/accounts.ts +11 -5
- package/src/hooks/browser.ts +11 -0
- package/src/hooks/global.ts +170 -7
- package/src/hooks/index.ts +1 -2
- package/src/hooks/settings.ts +28 -37
- package/src/hooks/transactions.ts +28 -155
- package/src/hooks/ui.ts +232 -36
- package/src/index.ts +33 -24
- package/src/reducers/accounts.ts +19 -2
- package/src/reducers/browser.ts +223 -0
- package/src/reducers/global.ts +67 -1
- package/src/reducers/index.ts +1 -0
- package/src/reducers/transactions.ts +0 -9
- package/src/reducers/ui.ts +127 -8
- package/src/types/index.ts +1 -1
- package/src/ui-hooks/index.ts +107 -0
- package/src/ui-hooks/useActionOverviewSectionLogic.ts +150 -0
- package/src/ui-hooks/useAddressTypeScreenLogic.ts +160 -0
- package/src/ui-hooks/useAlkanesBalanceCardLogic.ts +41 -0
- package/src/ui-hooks/useAlkanesCollectionListLogic.ts +68 -0
- package/src/ui-hooks/useAlkanesListLogic.ts +69 -0
- package/src/ui-hooks/useAlkanesNFTListLogic.ts +42 -0
- package/src/ui-hooks/useAlkanesNFTScreenLogic.ts +45 -0
- package/src/ui-hooks/useAlkanesTokenScreenLogic.ts +130 -0
- package/src/ui-hooks/useAmountInputLogic.ts +80 -0
- package/src/ui-hooks/useAnnouncementCardLogic.ts +91 -0
- package/src/ui-hooks/useBRC20BalanceCardLogic.ts +115 -0
- package/src/ui-hooks/useBRC20InscribeTransferLogic.ts +398 -0
- package/src/ui-hooks/useBRC20ListLogic.ts +75 -0
- package/src/ui-hooks/useBRC20ProgListLogic.ts +77 -0
- package/src/ui-hooks/useBRC20SendScreenLogic.ts +411 -0
- package/src/ui-hooks/useBRC20SingleStepScreenLogic.ts +208 -0
- package/src/ui-hooks/useBRC20TokenScreenLogic.ts +469 -0
- package/src/ui-hooks/useBalanceCardLogic.ts +164 -0
- package/src/ui-hooks/useBtcDisplayLogic.ts +16 -0
- package/src/ui-hooks/useCAT20BalanceCardLogic.ts +35 -0
- package/src/ui-hooks/useCAT20ListLogic.ts +83 -0
- package/src/ui-hooks/useCAT20TokenScreenLogic.ts +122 -0
- package/src/ui-hooks/useCAT721ListLogic.ts +68 -0
- package/src/ui-hooks/useCAT721NFTScreenLogic.ts +37 -0
- package/src/ui-hooks/useCreatePasswordScreenLogic.ts +92 -0
- package/src/ui-hooks/useCreateWalletLogicImportWordsStep.ts +299 -0
- package/src/ui-hooks/useEditAccountNameScreenLogic.ts +71 -0
- package/src/ui-hooks/useEditContactScreenLogic.ts +162 -0
- package/src/ui-hooks/useEditWalletNameScreenLogic.ts +58 -0
- package/src/ui-hooks/useExportMnemonicsScreenLogic.ts +75 -0
- package/src/ui-hooks/useExportPrivateKeyScreenLogic.ts +64 -0
- package/src/ui-hooks/useFeeRateBarLogic.ts +303 -0
- package/src/ui-hooks/useInfiniteList.ts +85 -0
- package/src/ui-hooks/useInscriptionListLogic.ts +68 -0
- package/src/ui-hooks/useLockTimePageLogic.ts +43 -0
- package/src/ui-hooks/useNotificationsLogic.ts +115 -0
- package/src/ui-hooks/useOrdinalsInscriptionScreenLogic.ts +130 -0
- package/src/ui-hooks/useRunesBalanceCardLogic.ts +44 -0
- package/src/ui-hooks/useRunesListLogic.ts +74 -0
- package/src/ui-hooks/useRunesTokenScreenLogic.ts +149 -0
- package/src/ui-hooks/useSecurityCardLogic.ts +0 -0
- package/src/ui-hooks/useSendAlkanesNFTScreenLogic.ts +138 -0
- package/src/ui-hooks/useSendAlkanesScreenLogic.ts +192 -0
- package/src/ui-hooks/useSendCAT20ScreenLogic.ts +297 -0
- package/src/ui-hooks/useSendCAT721ScreenLogic.ts +205 -0
- package/src/ui-hooks/useSendOrdinalsInscriptionScreenLogic.ts +137 -0
- package/src/ui-hooks/useSendRunesScreenLogic.ts +172 -0
- package/src/ui-hooks/useSettingsTabScreenLogic.ts +211 -0
- package/src/ui-hooks/useSignMessageLogic.ts +302 -0
- package/src/ui-hooks/useSignPsbtLogic.ts +517 -0
- package/src/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.ts +95 -0
- package/src/ui-hooks/useTxConfirmScreenLogic.ts +47 -0
- package/src/ui-hooks/useTxCreateScreenLogic.ts +161 -0
- package/src/ui-hooks/useTxFailScreenLogic.ts +26 -0
- package/src/ui-hooks/useTxSuccessScreenLogic.ts +33 -0
- package/src/updater/accounts.ts +11 -11
- package/src/utils/bitcoin-utils.ts +17 -8
- package/src/utils/eventBus.ts +2 -1
- package/src/utils/password-utils.ts +78 -0
- package/src/utils/ui-utils.ts +28 -0
- package/src/hooks/approval.ts +0 -72
- package/src/hooks/i18n.ts +0 -53
- package/src/utils/i18n.ts +0 -41
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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<
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
autoFinalized: boolean
|
|
207
|
-
): Promise<string>
|
|
237
|
+
signPsbtV2(toSignData: ToSignData): Promise<SignedData>
|
|
238
|
+
|
|
239
|
+
signMessage(params: ToSignMessage): Promise<SignedMessage>
|
|
208
240
|
|
|
209
|
-
|
|
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
|
-
|
|
250
|
+
createSendAllBTCPsbt(data: {
|
|
224
251
|
to: string
|
|
225
252
|
btcUtxos: UnspentOutput[]
|
|
226
253
|
feeRate: number
|
|
227
|
-
|
|
228
|
-
}): Promise<{
|
|
229
|
-
psbtHex: string
|
|
230
|
-
rawtx: string
|
|
231
|
-
fee: number
|
|
232
|
-
}>
|
|
254
|
+
}): Promise<ToSignData>
|
|
233
255
|
|
|
234
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
483
|
+
): Promise<{ id: string; feeRate: number; toSignData: ToSignData }>
|
|
479
484
|
transferCAT20Step2(
|
|
480
485
|
version: 'v1' | 'v2',
|
|
481
486
|
transferId: string,
|
|
482
|
-
|
|
483
|
-
|
|
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
|
-
|
|
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;
|
|
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;
|
|
530
|
+
): Promise<{ id: string; feeRate: number; toSignData: ToSignData }>
|
|
528
531
|
transferCAT721Step2(
|
|
529
532
|
version: 'v1' | 'v2',
|
|
530
533
|
transferId: string,
|
|
531
|
-
|
|
532
|
-
|
|
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
|
-
|
|
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
|
-
|
|
597
|
-
toSignInputs: UserToSignInput[]
|
|
597
|
+
toSignData: ToSignData
|
|
598
598
|
}>
|
|
599
599
|
|
|
600
|
-
singleStepTransferBRC20Step2(params: {
|
|
601
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
666
|
-
}): Promise<
|
|
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
|
|
package/src/context/index.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
export {
|
|
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'
|
package/src/hooks/accounts.ts
CHANGED
|
@@ -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 {
|
|
10
|
-
import {
|
|
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 {
|
|
14
|
-
import {
|
|
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
|
+
}
|