@@ -502,4 +502,85 @@ describe('useTransactionParser hook', () => {
502
502
} )
503
503
} )
504
504
} )
505
+ describe ( 'check for token symbol' , ( ) => {
506
+ describe . each ( [
507
+ [ 'ERC20Approve' , TransactionType . ERC20Approve ] ,
508
+ [ 'ERC20Transfer' , TransactionType . ERC20Transfer ] ,
509
+ [ 'ERC721TransferFrom' , TransactionType . ERC721TransferFrom ] ,
510
+ [ 'ERC721SafeTransferFrom' , TransactionType . ERC721SafeTransferFrom ]
511
+ ] ) ( '%s' , ( _ , txType ) => {
512
+ it ( 'should be empty' , ( ) => {
513
+ const { result : { current : transactionParser } } = renderHook ( ( ) => useTransactionParser (
514
+ mockNetwork , [ mockAccount ] , [ ] , [ mockERC20Token ]
515
+ ) )
516
+
517
+ const mockTransactionInfo = getMockedTransactionInfo ( )
518
+ const parsedTransaction = transactionParser ( {
519
+ ...mockTransactionInfo ,
520
+ txType,
521
+ txData : {
522
+ ...mockTransactionInfo . txData ,
523
+ baseData : {
524
+ ...mockTransactionInfo . txData . baseData ,
525
+ to : 'test'
526
+ }
527
+ } ,
528
+ txArgs : [
529
+ 'mockRecipient' ,
530
+ '0xde0b6b3a7640000'
531
+ ]
532
+ } )
533
+
534
+ expect ( parsedTransaction . symbol ) . toEqual ( '' )
535
+ } )
536
+ it ( 'Gets token symbol from visibleList, should be DOG' , ( ) => {
537
+ const { result : { current : transactionParser } } = renderHook ( ( ) => useTransactionParser (
538
+ mockNetwork , [ mockAccount ] , [ ] , [ mockERC20Token ]
539
+ ) )
540
+
541
+ const mockTransactionInfo = getMockedTransactionInfo ( )
542
+ const parsedTransaction = transactionParser ( {
543
+ ...mockTransactionInfo ,
544
+ txType,
545
+ txData : {
546
+ ...mockTransactionInfo . txData ,
547
+ baseData : {
548
+ ...mockTransactionInfo . txData . baseData ,
549
+ to : 'mockContractAddress'
550
+ }
551
+ } ,
552
+ txArgs : [
553
+ 'mockRecipient' ,
554
+ '0xde0b6b3a7640000'
555
+ ]
556
+ } )
557
+
558
+ expect ( parsedTransaction . symbol ) . toEqual ( 'DOG' )
559
+ } )
560
+ it ( 'Gets token symbol from fallback fullTokenList, should be DOG' , ( ) => {
561
+ const { result : { current : transactionParser } } = renderHook ( ( ) => useTransactionParser (
562
+ mockNetwork , [ mockAccount ] , [ ] , [ ] , [ mockERC20Token ]
563
+ ) )
564
+
565
+ const mockTransactionInfo = getMockedTransactionInfo ( )
566
+ const parsedTransaction = transactionParser ( {
567
+ ...mockTransactionInfo ,
568
+ txType,
569
+ txData : {
570
+ ...mockTransactionInfo . txData ,
571
+ baseData : {
572
+ ...mockTransactionInfo . txData . baseData ,
573
+ to : 'mockContractAddress'
574
+ }
575
+ } ,
576
+ txArgs : [
577
+ 'mockRecipient' ,
578
+ '0xde0b6b3a7640000'
579
+ ]
580
+ } )
581
+
582
+ expect ( parsedTransaction . symbol ) . toEqual ( 'DOG' )
583
+ } )
584
+ } )
585
+ } )
505
586
} )
0 commit comments