@@ -7,10 +7,14 @@ import { MultichainAggregatedAddressListRow } from './multichain-aggregated-list
77
88jest . mock ( '../../../hooks/useI18nContext' , ( ) => ( {
99useI18nContext :( ) => ( key :string ) => {
10- if ( key === 'networkNameEthereum' ) {
11- return 'Ethereum' ;
12- }
13- return key ;
10+ const translations :Record < string , string > = {
11+ networkNameEthereum :'Ethereum' ,
12+ networkNameBitcoinLegacy :'Legacy' ,
13+ networkNameBitcoinNestedSegwit :'Nested SegWit' ,
14+ networkNameBitcoinSegwit :'Native SegWit' ,
15+ networkNameBitcoinTaproot :'Taproot' ,
16+ } ;
17+ return translations [ key ] || key ;
1418} ,
1519} ) ) ;
1620
@@ -25,6 +29,15 @@ const TEST_STRINGS = {
2529EMPTY_STRING :'' ,
2630ETHEREUM_GROUP_NAME :'Ethereum' ,
2731SOLANA_NETWORK_NAME :'Solana Mainnet' ,
32+ BTC_LEGACY_ADDRESS :'1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' ,
33+ BTC_NESTED_SEGWIT_ADDRESS :'3FZbgi29cpjq2GjdwV8eyHuJJnkLtktZc5' ,
34+ BTC_NATIVE_SEGWIT_ADDRESS :'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4' ,
35+ BTC_TAPROOT_ADDRESS :
36+ 'bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr' ,
37+ BTC_LEGACY_TAG :'Legacy' ,
38+ BTC_NESTED_SEGWIT_TAG :'Nested SegWit' ,
39+ BTC_NATIVE_SEGWIT_TAG :'Native SegWit' ,
40+ BTC_TAPROOT_TAG :'Taproot' ,
2841} as const ;
2942
3043const TEST_CHAIN_IDS = {
@@ -40,6 +53,7 @@ const TEST_CHAIN_IDS = {
4053POLYGON_CAIP :'eip155:137' ,
4154ARBITRUM_CAIP :'eip155:42161' ,
4255SOLANA_CAIP :'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' ,
56+ BITCOIN_CAIP :'bip122:000000000019d6689c085ae165831e93' ,
4357} as const ;
4458
4559const TEST_IDS = {
@@ -444,4 +458,115 @@ describe('MultichainAggregatedAddressListRow', () => {
444458) . toBeInTheDocument ( ) ;
445459} ) ;
446460} ) ;
461+
462+ describe ( 'Bitcoin Address Tag' , ( ) => {
463+ it ( 'displays Legacy tag for P2PKH Bitcoin addresses' , ( ) => {
464+ const props = createTestProps ( {
465+ address :TEST_STRINGS . BTC_LEGACY_ADDRESS ,
466+ chainIds :[ TEST_CHAIN_IDS . BITCOIN_CAIP ] ,
467+ } ) ;
468+
469+ render (
470+ < Provider store = { store } >
471+ < MultichainAggregatedAddressListRow { ...props } />
472+ </ Provider > ,
473+ ) ;
474+
475+ expect ( screen . getByText ( TEST_STRINGS . BTC_LEGACY_TAG ) ) . toBeInTheDocument ( ) ;
476+ } ) ;
477+
478+ it ( 'displays Nested SegWit tag for P2SH Bitcoin addresses' , ( ) => {
479+ const props = createTestProps ( {
480+ address :TEST_STRINGS . BTC_NESTED_SEGWIT_ADDRESS ,
481+ chainIds :[ TEST_CHAIN_IDS . BITCOIN_CAIP ] ,
482+ } ) ;
483+
484+ render (
485+ < Provider store = { store } >
486+ < MultichainAggregatedAddressListRow { ...props } />
487+ </ Provider > ,
488+ ) ;
489+
490+ expect (
491+ screen . getByText ( TEST_STRINGS . BTC_NESTED_SEGWIT_TAG ) ,
492+ ) . toBeInTheDocument ( ) ;
493+ } ) ;
494+
495+ it ( 'displays Native SegWit tag for P2WPKH Bitcoin addresses' , ( ) => {
496+ const props = createTestProps ( {
497+ address :TEST_STRINGS . BTC_NATIVE_SEGWIT_ADDRESS ,
498+ chainIds :[ TEST_CHAIN_IDS . BITCOIN_CAIP ] ,
499+ } ) ;
500+
501+ render (
502+ < Provider store = { store } >
503+ < MultichainAggregatedAddressListRow { ...props } />
504+ </ Provider > ,
505+ ) ;
506+
507+ expect (
508+ screen . getByText ( TEST_STRINGS . BTC_NATIVE_SEGWIT_TAG ) ,
509+ ) . toBeInTheDocument ( ) ;
510+ } ) ;
511+
512+ it ( 'displays Taproot tag for P2TR Bitcoin addresses' , ( ) => {
513+ const props = createTestProps ( {
514+ address :TEST_STRINGS . BTC_TAPROOT_ADDRESS ,
515+ chainIds :[ TEST_CHAIN_IDS . BITCOIN_CAIP ] ,
516+ } ) ;
517+
518+ render (
519+ < Provider store = { store } >
520+ < MultichainAggregatedAddressListRow { ...props } />
521+ </ Provider > ,
522+ ) ;
523+
524+ expect (
525+ screen . getByText ( TEST_STRINGS . BTC_TAPROOT_TAG ) ,
526+ ) . toBeInTheDocument ( ) ;
527+ } ) ;
528+
529+ it ( 'does not display tag for non-Bitcoin addresses' , ( ) => {
530+ const props = createTestProps ( {
531+ address :TEST_STRINGS . FULL_ADDRESS ,
532+ chainIds :[ TEST_CHAIN_IDS . ETHEREUM_CAIP ] ,
533+ } ) ;
534+
535+ render (
536+ < Provider store = { store } >
537+ < MultichainAggregatedAddressListRow { ...props } />
538+ </ Provider > ,
539+ ) ;
540+
541+ expect (
542+ screen . queryByText ( TEST_STRINGS . BTC_LEGACY_TAG ) ,
543+ ) . not . toBeInTheDocument ( ) ;
544+ expect (
545+ screen . queryByText ( TEST_STRINGS . BTC_NESTED_SEGWIT_TAG ) ,
546+ ) . not . toBeInTheDocument ( ) ;
547+ expect (
548+ screen . queryByText ( TEST_STRINGS . BTC_NATIVE_SEGWIT_TAG ) ,
549+ ) . not . toBeInTheDocument ( ) ;
550+ expect (
551+ screen . queryByText ( TEST_STRINGS . BTC_TAPROOT_TAG ) ,
552+ ) . not . toBeInTheDocument ( ) ;
553+ } ) ;
554+
555+ it ( 'displays Bitcoin tag alongside Ethereum group name when address is Bitcoin' , ( ) => {
556+ const props = createTestProps ( {
557+ address :TEST_STRINGS . BTC_LEGACY_ADDRESS ,
558+ chainIds :[ TEST_CHAIN_IDS . BITCOIN_CAIP ] ,
559+ } ) ;
560+
561+ render (
562+ < Provider store = { store } >
563+ < MultichainAggregatedAddressListRow { ...props } />
564+ </ Provider > ,
565+ ) ;
566+
567+ const row = screen . getByTestId ( TEST_IDS . MULTICHAIN_ADDRESS_ROW ) ;
568+ expect ( row ) . toBeInTheDocument ( ) ;
569+ expect ( screen . getByText ( TEST_STRINGS . BTC_LEGACY_TAG ) ) . toBeInTheDocument ( ) ;
570+ } ) ;
571+ } ) ;
447572} ) ;