@unisat/wallet-state 1.0.0 → 1.0.2

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 (40) hide show
  1. package/lib/index.d.mts +934 -0
  2. package/lib/index.d.ts +934 -0
  3. package/lib/index.js +2225 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/index.mjs +2124 -0
  6. package/lib/index.mjs.map +1 -0
  7. package/package.json +19 -5
  8. package/src/actions/global.ts +5 -0
  9. package/src/context/I18nContext.tsx +191 -0
  10. package/src/context/PriceContext.tsx +81 -0
  11. package/src/context/WalletContext.tsx +703 -0
  12. package/src/context/index.ts +3 -0
  13. package/src/hooks/accounts.ts +23 -21
  14. package/src/hooks/approval.ts +72 -0
  15. package/src/hooks/base.ts +6 -0
  16. package/src/hooks/discovery.ts +29 -0
  17. package/src/hooks/global.ts +129 -5
  18. package/src/hooks/i18n.ts +53 -0
  19. package/src/hooks/index.ts +9 -15
  20. package/src/hooks/keyrings.ts +14 -5
  21. package/src/hooks/settings.ts +318 -5
  22. package/src/hooks/transactions.ts +44 -38
  23. package/src/hooks/ui.ts +133 -5
  24. package/src/index.ts +42 -5
  25. package/src/{slices → reducers}/accounts.ts +12 -12
  26. package/src/reducers/discovery.ts +73 -0
  27. package/src/reducers/global.ts +51 -0
  28. package/src/{slices → reducers}/keyrings.ts +7 -6
  29. package/src/{slices → reducers}/settings.ts +5 -5
  30. package/src/{slices → reducers}/transactions.ts +4 -5
  31. package/src/{slices → reducers}/ui.ts +4 -5
  32. package/src/updater/accounts.ts +107 -0
  33. package/src/updater/index.ts +1 -0
  34. package/src/utils/bitcoin-utils.ts +81 -0
  35. package/src/utils/eventBus.ts +49 -0
  36. package/src/utils/i18n.ts +41 -0
  37. package/src/slices/global.ts +0 -52
  38. package/src/slices/index.ts +0 -10
  39. package/src/store/index.ts +0 -43
  40. package/src/types/index.ts +0 -37
@@ -0,0 +1,703 @@
1
+ import { createContext, ReactNode, useContext } from 'react'
2
+
3
+ import {
4
+ Account,
5
+ AddressAlkanesTokenSummary,
6
+ AddressCAT20TokenSummary,
7
+ AddressCAT20UtxoSummary,
8
+ AddressCAT721CollectionSummary,
9
+ AddressRunesTokenSummary,
10
+ AddressSummary,
11
+ AddressTokenSummary,
12
+ AlkanesBalance,
13
+ AlkanesCollection,
14
+ AlkanesInfo,
15
+ AppInfo,
16
+ AppSummary,
17
+ BabylonAddressSummary,
18
+ BitcoinBalance,
19
+ BitcoinBalanceV2,
20
+ BRC20HistoryItem,
21
+ BtcChannelItem,
22
+ CAT20Balance,
23
+ CAT20MergeOrder,
24
+ CAT721Balance,
25
+ CoinPrice,
26
+ CosmosBalance,
27
+ CosmosSignDataType,
28
+ DecodedPsbt,
29
+ FeeSummary,
30
+ InscribeOrder,
31
+ Inscription,
32
+ InscriptionSummary,
33
+ RuneBalance,
34
+ SignPsbtOptions,
35
+ TickPriceItem,
36
+ TokenBalance,
37
+ TokenTransfer,
38
+ TxHistoryItem,
39
+ UserToSignInput,
40
+ UTXO,
41
+ UTXO_Detail,
42
+ VersionDetail,
43
+ WalletConfig,
44
+ WalletKeyring,
45
+ WebsiteResult,
46
+ ToSignInput,
47
+ UnspentOutput,
48
+ AddressFlagType,
49
+ ConnectedSite,
50
+ } from '@unisat/wallet-shared'
51
+ import { BabylonConfigV2 } from '@unisat/babylon-service/types'
52
+ import { AddressType, ChainType, NetworkType } from '@unisat/wallet-types'
53
+
54
+ interface ContactBookItem {
55
+ name: string
56
+ address: string
57
+ chain: ChainType
58
+ isAlias: boolean
59
+ isContact: boolean
60
+ sortIndex?: number
61
+ }
62
+ type ContactBookStore = Record<string, ContactBookItem | undefined>
63
+
64
+ export interface WalletController {
65
+ openapi: {
66
+ [key: string]: (...params: any) => Promise<any>
67
+ }
68
+
69
+ boot(password: string): Promise<void>
70
+ isBooted(): Promise<boolean>
71
+
72
+ getApproval(): Promise<any>
73
+ resolveApproval(data?: any, data2?: any): Promise<void>
74
+ rejectApproval(data?: any, data2?: any, data3?: any): Promise<void>
75
+
76
+ hasVault(): Promise<boolean>
77
+
78
+ verifyPassword(password: string): Promise<void>
79
+ changePassword: (password: string, newPassword: string) => Promise<void>
80
+
81
+ unlock(password: string): Promise<void>
82
+ isUnlocked(): Promise<boolean>
83
+
84
+ lockWallet(): Promise<void>
85
+ setPopupOpen(isOpen: boolean): void
86
+ isReady(): Promise<boolean>
87
+
88
+ getIsFirstOpen(): Promise<boolean>
89
+ updateIsFirstOpen(): Promise<void>
90
+
91
+ getAddressBalanceV2(address: string): Promise<BitcoinBalanceV2>
92
+ getAddressBalance(address: string): Promise<BitcoinBalance>
93
+ getAddressCacheBalance(address: string): Promise<BitcoinBalance>
94
+ getMultiAddressAssets(addresses: string): Promise<AddressSummary[]>
95
+ findGroupAssets(
96
+ groups: { type: number; address_arr: string[]; pubkey_arr: string[] }[]
97
+ ): Promise<
98
+ { type: number; address_arr: string[]; pubkey_arr: string[]; satoshis_arr: number[] }[]
99
+ >
100
+
101
+ getAddressInscriptions(
102
+ address: string,
103
+ cursor: number,
104
+ size: number
105
+ ): Promise<{ list: Inscription[]; total: number }>
106
+
107
+ getAddressHistory: (params: {
108
+ address: string
109
+ start: number
110
+ limit: number
111
+ }) => Promise<{ start: number; total: number; detail: TxHistoryItem[] }>
112
+ getAddressCacheHistory: (address: string) => Promise<TxHistoryItem[]>
113
+
114
+ getLocale(): Promise<string>
115
+ setLocale(locale: string): Promise<void>
116
+
117
+ getCurrency(): Promise<string>
118
+ setCurrency(currency: string): Promise<void>
119
+
120
+ clearKeyrings(): Promise<void>
121
+ getPrivateKey(
122
+ password: string,
123
+ account: { address: string; type: string }
124
+ ): Promise<{ hex: string; wif: string }>
125
+ getMnemonics(
126
+ password: string,
127
+ keyring: WalletKeyring
128
+ ): Promise<{
129
+ hdPath: string
130
+ mnemonic: string
131
+ passphrase: string
132
+ }>
133
+ createKeyringWithPrivateKey(
134
+ data: string,
135
+ addressType: AddressType,
136
+ alianName?: string
137
+ ): Promise<Account[]>
138
+ getPreMnemonics(): Promise<any>
139
+ generatePreMnemonic(): Promise<string>
140
+ removePreMnemonics(): void
141
+ createKeyringWithMnemonics(
142
+ mnemonic: string,
143
+ hdPath: string,
144
+ passphrase: string,
145
+ addressType: AddressType,
146
+ accountCount: number
147
+ ): Promise<{ address: string; type: string }[]>
148
+ createKeyringWithKeystone(
149
+ urType: string,
150
+ urCbor: string,
151
+ addressType: AddressType,
152
+ hdPath: string,
153
+ accountCount: number,
154
+ filterPubkey?: string[],
155
+ connectionType?: 'USB' | 'QR'
156
+ ): Promise<{ address: string; type: string }[]>
157
+ createTmpKeyringWithPrivateKey(
158
+ privateKey: string,
159
+ addressType: AddressType
160
+ ): Promise<WalletKeyring>
161
+ createTmpKeyringWithKeystone(
162
+ urType: string,
163
+ urCbor: string,
164
+ addressType: AddressType,
165
+ hdPath: string,
166
+ accountCount?: number
167
+ ): Promise<WalletKeyring>
168
+
169
+ createKeyringWithColdWallet(
170
+ xpub: string,
171
+ addressType: AddressType,
172
+ alianName?: string,
173
+ hdPath?: string,
174
+ accountCount?: number
175
+ ): Promise<WalletKeyring>
176
+
177
+ deriveAccountsFromXpub(
178
+ xpub: string,
179
+ addressType: AddressType,
180
+ hdPath?: string,
181
+ accountCount?: number
182
+ ): Promise<{ pubkey: string; address: string }[]>
183
+
184
+ createTmpKeyringWithMnemonics(
185
+ mnemonic: string,
186
+ hdPath: string,
187
+ passphrase: string,
188
+ addressType: AddressType,
189
+ accountCount?: number
190
+ ): Promise<WalletKeyring>
191
+ removeKeyring(keyring: WalletKeyring): Promise<WalletKeyring>
192
+ deriveNewAccountFromMnemonic(keyring: WalletKeyring, alianName?: string): Promise<string[]>
193
+ getAccountsCount(): Promise<number>
194
+ getAllAlianName: () => (ContactBookItem | undefined)[]
195
+ getContactsByMap: () => ContactBookStore
196
+
197
+ getCurrentAccount(): Promise<Account>
198
+ getAccounts(): Promise<Account[]>
199
+ getNextAlianName: (keyring: WalletKeyring) => Promise<string>
200
+
201
+ getCurrentKeyringAccounts(): Promise<Account[]>
202
+
203
+ signPsbtWithHex(
204
+ psbtHex: string,
205
+ toSignInputs: ToSignInput[],
206
+ autoFinalized: boolean
207
+ ): Promise<string>
208
+
209
+ sendBTC(data: {
210
+ to: string
211
+ amount: number
212
+ btcUtxos: UnspentOutput[]
213
+ feeRate: number
214
+ enableRBF: boolean
215
+ memo?: string
216
+ memos?: string[]
217
+ }): Promise<{
218
+ psbtHex: string
219
+ rawtx: string
220
+ fee: number
221
+ }>
222
+
223
+ sendAllBTC(data: {
224
+ to: string
225
+ btcUtxos: UnspentOutput[]
226
+ feeRate: number
227
+ enableRBF: boolean
228
+ }): Promise<{
229
+ psbtHex: string
230
+ rawtx: string
231
+ fee: number
232
+ }>
233
+
234
+ sendOrdinalsInscription(data: {
235
+ to: string
236
+ inscriptionId: string
237
+ feeRate: number
238
+ outputValue?: number
239
+ enableRBF: boolean
240
+ btcUtxos: UnspentOutput[]
241
+ }): Promise<{
242
+ psbtHex: string
243
+ rawtx: string
244
+ fee: number
245
+ }>
246
+
247
+ sendOrdinalsInscriptions(data: {
248
+ to: string
249
+ inscriptionIds: string[]
250
+ feeRate: number
251
+ enableRBF: boolean
252
+ btcUtxos: UnspentOutput[]
253
+ }): Promise<{
254
+ psbtHex: string
255
+ rawtx: string
256
+ fee: number
257
+ }>
258
+
259
+ splitOrdinalsInscription(data: {
260
+ inscriptionId: string
261
+ feeRate: number
262
+ outputValue: number
263
+ enableRBF: boolean
264
+ btcUtxos: UnspentOutput[]
265
+ }): Promise<{
266
+ psbtHex: string
267
+ rawtx: string
268
+ fee: number
269
+ splitedCount: number
270
+ }>
271
+
272
+ pushTx(rawtx: string): Promise<string>
273
+
274
+ queryDomainInfo(domain: string): Promise<Inscription>
275
+
276
+ getInscriptionSummary(): Promise<InscriptionSummary>
277
+ getAppSummary(): Promise<AppSummary>
278
+ getBTCUtxos(): Promise<UnspentOutput[]>
279
+ getAssetUtxosInscriptions(inscriptionId: string): Promise<UnspentOutput[]>
280
+
281
+ getNetworkType(): Promise<NetworkType>
282
+ setNetworkType(type: NetworkType): Promise<void>
283
+
284
+ getChainType(): Promise<ChainType>
285
+ setChainType(type: ChainType): Promise<void>
286
+
287
+ getConnectedSites(): Promise<ConnectedSite[]>
288
+ removeConnectedSite(origin: string): Promise<void>
289
+ getCurrentConnectedSite(id: string): Promise<ConnectedSite>
290
+
291
+ getCurrentKeyring(): Promise<WalletKeyring>
292
+ getKeyrings(): Promise<WalletKeyring[]>
293
+ changeKeyring(keyring: WalletKeyring, accountIndex?: number): Promise<void>
294
+ getAllAddresses(keyring: WalletKeyring, index: number): Promise<string[]>
295
+
296
+ setKeyringAlianName(keyring: WalletKeyring, name: string): Promise<WalletKeyring>
297
+ changeAddressType(addressType: AddressType): Promise<void>
298
+
299
+ setAccountAlianName(account: Account, name: string): Promise<Account>
300
+ getFeeSummary(): Promise<FeeSummary>
301
+ getCoinPrice(): Promise<CoinPrice>
302
+ getBrc20sPrice(ticks: string[]): Promise<{ [tick: string]: TickPriceItem }>
303
+ getRunesPrice(ticks: string[]): Promise<{ [tick: string]: TickPriceItem }>
304
+ getCAT20sPrice(tokenIds: string[]): Promise<{ [tokenId: string]: TickPriceItem }>
305
+ getAlkanesPrice(alkaneid: string[]): Promise<{ [tick: string]: TickPriceItem }>
306
+
307
+ setEditingKeyring(keyringIndex: number): Promise<void>
308
+ getEditingKeyring(): Promise<WalletKeyring>
309
+
310
+ setEditingAccount(account: Account): Promise<void>
311
+ getEditingAccount(): Promise<Account>
312
+
313
+ inscribeBRC20Transfer(
314
+ address: string,
315
+ tick: string,
316
+ amount: string,
317
+ feeRate: number,
318
+ outputValue: number
319
+ ): Promise<InscribeOrder>
320
+ getInscribeResult(orderId: string): Promise<TokenTransfer>
321
+
322
+ decodePsbt(psbtHex: string, website: string): Promise<DecodedPsbt>
323
+
324
+ decodeContracts(contracts: any[], account: any): Promise<any[]>
325
+
326
+ getAllInscriptionList(
327
+ address: string,
328
+ currentPage: number,
329
+ pageSize: number
330
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: Inscription[] }>
331
+
332
+ getBRC20List(
333
+ address: string,
334
+ currentPage: number,
335
+ pageSize: number
336
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: TokenBalance[] }>
337
+
338
+ getBRC20ProgList(
339
+ address: string,
340
+ currentPage: number,
341
+ pageSize: number
342
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: TokenBalance[] }>
343
+
344
+ getBRC20TransferableList(
345
+ address: string,
346
+ ticker: string,
347
+ currentPage: number,
348
+ pageSize: number
349
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: TokenTransfer[] }>
350
+
351
+ getOrdinalsInscriptions(
352
+ address: string,
353
+ currentPage: number,
354
+ pageSize: number
355
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: Inscription[] }>
356
+
357
+ getBRC20Summary(address: string, ticker: string): Promise<AddressTokenSummary>
358
+
359
+ expireUICachedData(address: string): Promise<void>
360
+
361
+ getWalletConfig(): Promise<WalletConfig>
362
+
363
+ getSkippedVersion(): Promise<string>
364
+ setSkippedVersion(version: string): Promise<void>
365
+
366
+ getInscriptionUtxoDetail(inscriptionId: string): Promise<UTXO_Detail>
367
+ getUtxoByInscriptionId(inscriptionId: string): Promise<UTXO>
368
+ getInscriptionInfo(inscriptionId: string): Promise<Inscription>
369
+
370
+ checkWebsite(website: string): Promise<WebsiteResult>
371
+
372
+ readTab(tabName: string): Promise<void>
373
+ readApp(appid: number): Promise<void>
374
+
375
+ formatOptionsToSignInputs(psbtHex: string, options?: SignPsbtOptions): Promise<ToSignInput[]>
376
+
377
+ getAddressSummary(address: string): Promise<AddressSummary>
378
+
379
+ getShowSafeNotice(): Promise<boolean>
380
+ setShowSafeNotice(show: boolean): Promise<void>
381
+
382
+ // address flag
383
+ addAddressFlag(account: Account, flag: AddressFlagType): Promise<Account>
384
+ removeAddressFlag(account: Account, flag: AddressFlagType): Promise<Account>
385
+
386
+ getVersionDetail(version: string): Promise<VersionDetail>
387
+
388
+ genSignPsbtUr(psbtHex: string): Promise<{ type: string; cbor: string }>
389
+ parseSignPsbtUr(
390
+ type: string,
391
+ cbor: string,
392
+ isFinalize?: boolean
393
+ ): Promise<{ psbtHex: string; rawtx?: string }>
394
+ genSignMsgUr(
395
+ text: string,
396
+ msgType?: string
397
+ ): Promise<{ type: string; cbor: string; requestId: string }>
398
+ parseSignMsgUr(type: string, cbor: string, msgType: string): Promise<{ signature: string }>
399
+ getKeystoneConnectionType(): Promise<'USB' | 'QR'>
400
+ genSignCosmosUr(cosmosSignRequest: {
401
+ requestId?: string
402
+ signData: string
403
+ dataType: CosmosSignDataType
404
+ path: string
405
+ chainId?: string
406
+ accountNumber?: string
407
+ address?: string
408
+ }): Promise<{ type: string; cbor: string; requestId: string }>
409
+ parseCosmosSignUr(type: string, cbor: string): Promise<any>
410
+
411
+ cosmosSignData(
412
+ chainId: string,
413
+ signBytesHex: string
414
+ ): Promise<{
415
+ publicKey: string
416
+ signature: string
417
+ }>
418
+
419
+ getEnableSignData(): Promise<boolean>
420
+ setEnableSignData(enable: boolean): Promise<void>
421
+
422
+ getRunesList(
423
+ address: string,
424
+ currentPage: number,
425
+ pageSize: number
426
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: RuneBalance[] }>
427
+
428
+ getAssetUtxosRunes(rune: string): Promise<UnspentOutput[]>
429
+
430
+ getAddressRunesTokenSummary(address: string, runeid: string): Promise<AddressRunesTokenSummary>
431
+
432
+ sendRunes(data: {
433
+ to: string
434
+ runeid: string
435
+ runeAmount: string
436
+ feeRate: number
437
+ enableRBF: boolean
438
+ btcUtxos?: UnspentOutput[]
439
+ assetUtxos?: UnspentOutput[]
440
+ outputValue?: number
441
+ }): Promise<{
442
+ psbtHex: string
443
+ rawtx: string
444
+ fee: number
445
+ }>
446
+
447
+ setAutoLockTimeId(timeId: number): Promise<void>
448
+ getAutoLockTimeId(): Promise<number>
449
+
450
+ getDeveloperMode(): Promise<boolean>
451
+ setDeveloperMode(developerMode: boolean): Promise<void>
452
+
453
+ getCAT20List(
454
+ version: 'v1' | 'v2',
455
+ address: string,
456
+ currentPage: number,
457
+ pageSize: number
458
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: CAT20Balance[] }>
459
+
460
+ getAddressCAT20TokenSummary(
461
+ version: 'v1' | 'v2',
462
+ address: string,
463
+ tokenId: string
464
+ ): Promise<AddressCAT20TokenSummary>
465
+
466
+ getAddressCAT20UtxoSummary(
467
+ version: 'v1' | 'v2',
468
+ address: string,
469
+ tokenId: string
470
+ ): Promise<AddressCAT20UtxoSummary>
471
+
472
+ transferCAT20Step1(
473
+ version: 'v1' | 'v2',
474
+ to: string,
475
+ tokenId: string,
476
+ tokenAmount: string,
477
+ feeRate: number
478
+ ): Promise<{ id: string; commitTx: string; toSignInputs: UserToSignInput[]; feeRate: number }>
479
+ transferCAT20Step2(
480
+ version: 'v1' | 'v2',
481
+ transferId: string,
482
+ commitTx: string,
483
+ toSignInputs: UserToSignInput[]
484
+ ): Promise<{ revealTx: string; toSignInputs: UserToSignInput[] }>
485
+ transferCAT20Step3(
486
+ version: 'v1' | 'v2',
487
+ transferId: string,
488
+ revealTx: string,
489
+ toSignInputs: UserToSignInput[]
490
+ ): Promise<{ txid: string }>
491
+
492
+ mergeCAT20Prepare(
493
+ version: 'v1' | 'v2',
494
+ tokenId: string,
495
+ utxoCount: number,
496
+ feeRate: number
497
+ ): Promise<CAT20MergeOrder>
498
+ transferCAT20Step1ByMerge(
499
+ version: 'v1' | 'v2',
500
+ mergeId: string
501
+ ): Promise<{ id: string; commitTx: string; toSignInputs: UserToSignInput[]; feeRate: number }>
502
+ getMergeCAT20Status(version: 'v1' | 'v2', mergeId: string): Promise<any>
503
+
504
+ getAppList(): Promise<{ tab: string; items: AppInfo[] }[]>
505
+ getBannerList(): Promise<{ id: string; img: string; link: string }[]>
506
+ getBlockActiveInfo(): Promise<{ allTransactions: number; allAddrs: number }>
507
+
508
+ getCAT721List(
509
+ version: 'v1' | 'v2',
510
+ address: string,
511
+ currentPage: number,
512
+ pageSize: number
513
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: CAT721Balance[] }>
514
+
515
+ getAddressCAT721CollectionSummary(
516
+ version: 'v1' | 'v2',
517
+ address: string,
518
+ collectionId: string
519
+ ): Promise<AddressCAT721CollectionSummary>
520
+
521
+ transferCAT721Step1(
522
+ version: 'v1' | 'v2',
523
+ to: string,
524
+ collectionId: string,
525
+ localId: string,
526
+ feeRate: number
527
+ ): Promise<{ id: string; commitTx: string; toSignInputs: UserToSignInput[]; feeRate: number }>
528
+ transferCAT721Step2(
529
+ version: 'v1' | 'v2',
530
+ transferId: string,
531
+ commitTx: string,
532
+ toSignInputs: UserToSignInput[]
533
+ ): Promise<{ revealTx: string; toSignInputs: UserToSignInput[] }>
534
+ transferCAT721Step3(
535
+ version: 'v1' | 'v2',
536
+ transferId: string,
537
+ revealTx: string,
538
+ toSignInputs: UserToSignInput[]
539
+ ): Promise<{ txid: string }>
540
+
541
+ getBuyCoinChannelList(coin: string): Promise<BtcChannelItem[]>
542
+ createBuyCoinPaymentUrl(coin: string, address: string, channel: string): Promise<string>
543
+
544
+ getBabylonAddress(address: string): Promise<string>
545
+
546
+ getBabylonAddressSummary(
547
+ chainId: string,
548
+ babylonConfig?: BabylonConfigV2
549
+ ): Promise<BabylonAddressSummary>
550
+
551
+ createSendTokenStep1(
552
+ chainId: string,
553
+ tokenBalance: CosmosBalance,
554
+ to: string,
555
+ memo: string,
556
+ {
557
+ gasLimit,
558
+ gasPrice,
559
+ gasAdjustment,
560
+ }: {
561
+ gasLimit: number
562
+ gasPrice: string
563
+ gasAdjustment?: number
564
+ }
565
+ ): Promise<string>
566
+ createSendTokenStep2(chainId: string, signature: string): Promise<string>
567
+
568
+ simulateBabylonGas(
569
+ chainId: string,
570
+ recipient: string,
571
+ amount: { denom: string; amount: string },
572
+ memo: string
573
+ ): Promise<number>
574
+
575
+ getBabylonConfig(): Promise<BabylonConfigV2>
576
+
577
+ getContactByAddress(address: string): Promise<ContactBookItem | undefined>
578
+ getContactByAddressAndChain(
579
+ address: string,
580
+ chain: ChainType
581
+ ): Promise<ContactBookItem | undefined>
582
+ updateContact(data: ContactBookItem): Promise<void>
583
+ removeContact(address: string, chain?: ChainType): Promise<void>
584
+ listContacts(): Promise<ContactBookItem[]>
585
+ saveContactsOrder(contacts: ContactBookItem[]): Promise<void>
586
+
587
+ singleStepTransferBRC20Step1(params: {
588
+ userAddress: string
589
+ userPubkey: string
590
+ receiver: string
591
+ ticker: string
592
+ amount: string
593
+ feeRate: number
594
+ }): Promise<{
595
+ orderId: string
596
+ psbtHex: string
597
+ toSignInputs: UserToSignInput[]
598
+ }>
599
+
600
+ singleStepTransferBRC20Step2(params: {
601
+ orderId: string
602
+ commitTx: string
603
+ toSignInputs: UserToSignInput[]
604
+ }): Promise<{
605
+ psbtHex: string
606
+ toSignInputs: UserToSignInput[]
607
+ }>
608
+
609
+ singleStepTransferBRC20Step3(params: {
610
+ orderId: string
611
+ revealTx: string
612
+ toSignInputs: UserToSignInput[]
613
+ }): Promise<{ txid: string }>
614
+
615
+ setLastActiveTime(): void
616
+
617
+ getOpenInSidePanel(): Promise<boolean>
618
+ setOpenInSidePanel(openInSidePanel: boolean): Promise<void>
619
+
620
+ sendCoinBypassHeadOffsets(
621
+ tos: { address: string; satoshis: number }[],
622
+ feeRate: number
623
+ ): Promise<{
624
+ psbtHex: string
625
+ rawtx: string
626
+ fee: number
627
+ }>
628
+
629
+ getAlkanesList(
630
+ address: string,
631
+ currentPage: number,
632
+ pageSize: number
633
+ ): Promise<{ currentPage: number; pageSize: number; total: number; list: AlkanesBalance[] }>
634
+
635
+ getAssetUtxosAlkanes(rune: string): Promise<UnspentOutput[]>
636
+
637
+ getAddressAlkanesTokenSummary(
638
+ address: string,
639
+ alkaneid: string,
640
+ fetchAvailable: boolean
641
+ ): Promise<AddressAlkanesTokenSummary>
642
+
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: {
661
+ to: string
662
+ alkaneid: string
663
+ amount: string
664
+ feeRate: number
665
+ enableRBF: boolean
666
+ }): Promise<string>
667
+
668
+ getAlkanesCollectionList(
669
+ address: string,
670
+ currentPage: number,
671
+ pageSize: number
672
+ ): Promise<{ list: AlkanesCollection[]; total: number }>
673
+ getAlkanesCollectionItems(
674
+ address: string,
675
+ collectionId: string,
676
+ currentPage: number,
677
+ pageSize: number
678
+ ): Promise<{ currentPage: number; pageSize: number; list: AlkanesInfo[]; total: number }>
679
+
680
+ getBRC20RecentHistory(address: string, ticker: string): Promise<BRC20HistoryItem[]>
681
+ }
682
+
683
+ const WalletContext = createContext<{
684
+ wallet: WalletController
685
+ } | null>(null)
686
+
687
+ const WalletProvider = ({
688
+ children,
689
+ wallet,
690
+ }: {
691
+ children?: ReactNode
692
+ wallet: WalletController
693
+ }) => <WalletContext.Provider value={{ wallet }}>{children}</WalletContext.Provider>
694
+
695
+ const useWallet = () => {
696
+ const { wallet } = useContext(WalletContext) as {
697
+ wallet: WalletController
698
+ }
699
+
700
+ return wallet
701
+ }
702
+
703
+ export { useWallet, WalletProvider }
@@ -0,0 +1,3 @@
1
+ export { I18nProvider } from './I18nContext'
2
+ export { useWallet, WalletProvider } from './WalletContext'
3
+ export { usePrice, PriceProvider } from './PriceContext'