7
7
PopiconsBulbLine ,
8
8
PopiconsCircleExclamationLine ,
9
9
PopiconsKeyLine ,
10
+ PopiconsOstrichSolid ,
10
11
} from "@popicons/react" ;
11
12
import dayjs from "dayjs" ;
12
13
import relativeTime from "dayjs/plugin/relativeTime" ;
@@ -17,14 +18,14 @@ import Alert from "~/app/components/Alert";
17
18
import BalanceBox from "~/app/components/BalanceBox" ;
18
19
import Hyperlink from "~/app/components/Hyperlink" ;
19
20
import { IconLinkCard } from "~/app/components/IconLinkCard/IconLinkCard" ;
20
- import SkeletonLoader from "~/app/components/SkeletonLoader" ;
21
21
import toast from "~/app/components/Toast" ;
22
22
import { useAccount } from "~/app/context/AccountContext" ;
23
23
import { useTransactions } from "~/app/hooks/useTransactions" ;
24
24
import { PublisherLnData } from "~/app/screens/Home/PublisherLnData" ;
25
25
import { isAlbyLNDHubAccount } from "~/app/utils" ;
26
26
import api , { GetAccountRes } from "~/common/lib/api" ;
27
27
import msg from "~/common/lib/msg" ;
28
+ import { default as nostr } from "~/common/lib/nostr" ;
28
29
import utils from "~/common/lib/utils" ;
29
30
import type { Battery } from "~/types" ;
30
31
@@ -50,6 +51,7 @@ const DefaultView: FC<Props> = (props) => {
50
51
51
52
const [ isBlockedUrl , setIsBlockedUrl ] = useState < boolean > ( false ) ;
52
53
const [ currentAccount , setCurrentAccount ] = useState < GetAccountRes > ( ) ;
54
+ const [ nostrPublicKey , setNostrPublicKey ] = useState ( "" ) ;
53
55
54
56
const { transactions, isLoadingTransactions, loadTransactions } =
55
57
useTransactions ( ) ;
@@ -78,6 +80,11 @@ const DefaultView: FC<Props> = (props) => {
78
80
( async ( ) => {
79
81
try {
80
82
const account = await api . getAccount ( ) ;
83
+ const nostrPrivateKey = await api . nostr . getPrivateKey ( account . id ) ;
84
+
85
+ setNostrPublicKey (
86
+ nostrPrivateKey ? await nostr . derivePublicKey ( nostrPrivateKey ) : ""
87
+ ) ;
81
88
setCurrentAccount ( account ) ;
82
89
} catch ( e ) {
83
90
console . error ( e ) ;
@@ -192,24 +199,42 @@ const DefaultView: FC<Props> = (props) => {
192
199
< BalanceBox />
193
200
) }
194
201
195
- { ( accountLoading || lightningAddress ) && (
196
- < div className = "flex justify-center" >
197
- < a
198
- className = "cursor-pointer flex flex-row items-center mb-6 px-3 py-1 bg-white dark:bg-surface-01dp border border-gray-200 dark:border-neutral-700 text-gray-800 dark:text-white rounded-full text-xs font-medium hover:border-primary hover:bg-yellow-50 dark:hover:border-primary dark:hover:dark:bg-surface-16dp transition-all duration-250 select-none"
199
- onClick = { ( ) => {
200
- navigator . clipboard . writeText ( lightningAddress ) ;
201
- toast . success ( tCommon ( "actions.copied_to_clipboard" ) ) ;
202
- } }
203
- >
204
- < img src = "assets/icons/popicons/bolt.svg" className = "mr-1" />
205
- { ! accountLoading ? (
206
- lightningAddress
207
- ) : (
208
- < SkeletonLoader className = "w-32" />
209
- ) }
210
- </ a >
202
+ { ( lightningAddress || nostrPublicKey ) && (
203
+ < div className = "flex justify-center gap-3 mb-2" >
204
+ { lightningAddress && (
205
+ < a
206
+ className = "relative group cursor-pointer flex flex-row items-center p-1 bg-white dark:bg-surface-01dp border border-gray-200 dark:border-neutral-700 text-gray-800 dark:text-white rounded-full text-xs font-medium hover:border-primary hover:bg-yellow-50 dark:hover:border-primary dark:hover:dark:bg-surface-16dp transition-all duration-250 select-none"
207
+ onClick = { ( ) => {
208
+ navigator . clipboard . writeText ( lightningAddress ) ;
209
+ toast . success ( tCommon ( "actions.copied_to_clipboard" ) ) ;
210
+ } }
211
+ >
212
+ < img src = "assets/icons/popicons/bolt.svg" className = "w-5 h-5" />
213
+ < span className = "max-w-64 hidden group-hover:block truncate mr-1" >
214
+ { lightningAddress }
215
+ </ span >
216
+ </ a >
217
+ ) }
218
+
219
+ { nostrPublicKey && (
220
+ < a
221
+ className = "relative group cursor-pointer flex flex-row items-center p-1 bg-white dark:bg-surface-01dp border border-gray-200 dark:border-neutral-700 text-gray-800 dark:text-white rounded-full text-xs font-medium hover:border-primary hover:bg-yellow-50 dark:hover:border-primary dark:hover:dark:bg-surface-16dp transition-all duration-250 select-none"
222
+ onClick = { ( ) => {
223
+ navigator . clipboard . writeText ( nostrPublicKey ) ;
224
+ toast . success ( tCommon ( "actions.copied_to_clipboard" ) ) ;
225
+ } }
226
+ >
227
+ < PopiconsOstrichSolid className = "w-5 h-5 text-purple-500" />
228
+ < span className = "max-w-64 hidden group-hover:block truncate mr-1" >
229
+ { nostrPublicKey . substring ( 0 , 11 ) }
230
+ ...
231
+ { nostrPublicKey . substring ( nostrPublicKey . length - 11 ) }
232
+ </ span >
233
+ </ a >
234
+ ) }
211
235
</ div >
212
236
) }
237
+
213
238
< div className = "flex space-x-3 justify-between" >
214
239
< HomeButton
215
240
icon = { < img src = "assets/icons/popicons/receive.svg" /> }
@@ -238,13 +263,13 @@ const DefaultView: FC<Props> = (props) => {
238
263
</ div >
239
264
240
265
{ isLoading && (
241
- < div className = "flex justify-center mt-4 " >
266
+ < div className = "flex justify-center" >
242
267
< Loading />
243
268
</ div >
244
269
) }
245
270
246
271
{ ! isLoading && (
247
- < div className = "mt-4 flex flex-col gap-4" >
272
+ < div className = "flex flex-col gap-4" >
248
273
{ ( transactions . length === 0 || needsKeySetup ) && (
249
274
< div className = "flex flex-col gap-2 md:gap-3" >
250
275
{ transactions . length === 0 && (
0 commit comments