Skip to content

Commit 9aa9f3c

Browse files
authored
ft: dex state streams filtering (#2860)
1 parent 9388a5a commit 9aa9f3c

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/features/feeds/components/FeedList.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ export const FeedList = ({
109109
const [showOnlyMVRFeeds, setShowOnlyMVRFeeds] = useState(false)
110110
const [showOnlyMVRFeedsTestnet, setShowOnlyMVRFeedsTestnet] = useState(false)
111111
const [showOnlySVR, setShowOnlySVR] = useState(false)
112+
const [showOnlyDEXFeeds, setShowOnlyDEXFeeds] = useState(false)
113+
const [showOnlyDEXFeedsTestnet, setShowOnlyDEXFeedsTestnet] = useState(false)
112114
const paginate = (pageNumber) => setCurrentPage(String(pageNumber))
113115
const addrPerPage = 8
114116
const lastAddr = Number(currentPage) * addrPerPage
@@ -439,6 +441,20 @@ export const FeedList = ({
439441
</button>
440442
)}
441443
</form>
444+
<div className={feedList.checkboxContainer}>
445+
<label className={feedList.detailsLabel}>
446+
<input
447+
type="checkbox"
448+
style="width:15px;height:15px;display:inline;margin-right:8px;"
449+
checked={showOnlyDEXFeeds}
450+
onChange={() => {
451+
setShowOnlyDEXFeeds((old) => !old)
452+
setCurrentPage("1") // Reset to first page when filter changes
453+
}}
454+
/>
455+
Show DEX State Price streams
456+
</label>
457+
</div>
442458
</div>
443459
{mainnetFeeds.length ? (
444460
mainnetFeeds.map((network) => (
@@ -454,6 +470,7 @@ export const FeedList = ({
454470
showExtraDetails={showExtraDetails}
455471
showOnlySVR={showOnlySVR}
456472
showOnlyMVRFeeds={showOnlyMVRFeeds}
473+
showOnlyDEXFeeds={showOnlyDEXFeeds}
457474
dataFeedType={dataFeedType}
458475
ecosystem={ecosystem}
459476
lastAddr={lastAddr}
@@ -503,6 +520,20 @@ export const FeedList = ({
503520
</button>
504521
)}
505522
</form>
523+
<div className={feedList.checkboxContainer}>
524+
<label className={feedList.detailsLabel}>
525+
<input
526+
type="checkbox"
527+
style="width:15px;height:15px;display:inline;margin-right:8px;"
528+
checked={showOnlyDEXFeedsTestnet}
529+
onChange={() => {
530+
setShowOnlyDEXFeedsTestnet((old) => !old)
531+
setTestnetCurrentPage("1") // Reset to first page when filter changes
532+
}}
533+
/>
534+
Show DEX State Price streams
535+
</label>
536+
</div>
506537
</div>
507538
{testnetFeeds.length ? (
508539
testnetFeeds.map((network) => (
@@ -519,6 +550,7 @@ export const FeedList = ({
519550
: []
520551
}
521552
showOnlyMVRFeeds={showOnlyMVRFeedsTestnet}
553+
showOnlyDEXFeeds={showOnlyDEXFeedsTestnet}
522554
firstAddr={testnetFirstAddr}
523555
lastAddr={testnetLastAddr}
524556
addrPerPage={testnetAddrPerPage}
@@ -805,6 +837,7 @@ export const FeedList = ({
805837
showExtraDetails={showExtraDetails}
806838
showOnlySVR={showOnlySVR}
807839
showOnlyMVRFeeds={showOnlyMVRFeeds}
840+
showOnlyDEXFeeds={false}
808841
dataFeedType={dataFeedType}
809842
ecosystem={ecosystem}
810843
lastAddr={lastAddr}

src/features/feeds/components/Tables.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ export const MainnetTable = ({
904904
showExtraDetails,
905905
showOnlySVR,
906906
showOnlyMVRFeeds,
907+
showOnlyDEXFeeds,
907908
dataFeedType,
908909
ecosystem,
909910
selectedFeedCategories,
@@ -918,6 +919,7 @@ export const MainnetTable = ({
918919
showExtraDetails: boolean
919920
showOnlySVR: boolean
920921
showOnlyMVRFeeds: boolean
922+
showOnlyDEXFeeds: boolean
921923
dataFeedType: string
922924
ecosystem: string
923925
selectedFeedCategories: string[]
@@ -945,10 +947,15 @@ export const MainnetTable = ({
945947
if (isDeprecating) return !!metadata.docs.shutdownDate
946948

947949
if (dataFeedType === "streamsCrypto") {
948-
return (
950+
const isValidStreamsFeed =
949951
metadata.contractType === "verifier" &&
950952
(metadata.docs.feedType === "Crypto" || metadata.docs.feedType === "Crypto-DEX")
951-
)
953+
954+
if (showOnlyDEXFeeds) {
955+
return isValidStreamsFeed && metadata.docs.feedType === "Crypto-DEX"
956+
}
957+
958+
return isValidStreamsFeed
952959
}
953960

954961
if (dataFeedType === "streamsRwa") {
@@ -1093,6 +1100,7 @@ export const TestnetTable = ({
10931100
},
10941101
searchValue = "",
10951102
showOnlyMVRFeeds,
1103+
showOnlyDEXFeeds,
10961104
}: {
10971105
network: ChainNetwork
10981106
showExtraDetails: boolean
@@ -1105,6 +1113,7 @@ export const TestnetTable = ({
11051113
paginate?: (page: number) => void
11061114
searchValue?: string
11071115
showOnlyMVRFeeds?: boolean
1116+
showOnlyDEXFeeds?: boolean
11081117
}) => {
11091118
if (!network.metadata) return null
11101119

@@ -1118,7 +1127,15 @@ export const TestnetTable = ({
11181127
.filter((metadata) => {
11191128
if (isStreams) {
11201129
if (dataFeedType === "streamsCrypto") {
1121-
return metadata.contractType === "verifier" && metadata.feedType === "Crypto"
1130+
const isValidStreamsFeed =
1131+
metadata.contractType === "verifier" &&
1132+
(metadata.feedType === "Crypto" || metadata.feedType === "Crypto-DEX")
1133+
1134+
if (showOnlyDEXFeeds) {
1135+
return isValidStreamsFeed && metadata.feedType === "Crypto-DEX"
1136+
}
1137+
1138+
return isValidStreamsFeed
11221139
}
11231140

11241141
if (dataFeedType === "streamsRwa") {

0 commit comments

Comments
 (0)