1- import { bech32 } from "bech32" ;
21import {
32 type Infinite ,
43 type DRepStatus ,
@@ -7,11 +6,7 @@ import {
76 DrepDataDTO ,
87} from "@models" ;
98import { API } from "../API" ;
10- import {
11- decodeCIP129Identifier ,
12- encodeCIP129Identifier ,
13- mapDtoToDrep ,
14- } from "@/utils" ;
9+ import { dRepSearchPhraseProcessor , mapDtoToDrep } from "@/utils" ;
1510
1611export type GetDRepListArguments = {
1712 filters ?: string [ ] ;
@@ -30,37 +25,7 @@ export const getDRepList = async ({
3025 searchPhrase : rawSearchPhrase = "" ,
3126 status = [ ] ,
3227} : GetDRepListArguments ) : Promise < Infinite < DRepData > > => {
33- // DBSync contains wrong representation of DRep view for script based DReps,
34- // but it's still used by BE
35- const searchPhraseProcessor = async ( ) => {
36- try {
37- if ( rawSearchPhrase . startsWith ( "drep_script" ) ) {
38- const { words } = bech32 . decode ( rawSearchPhrase ) ;
39- return bech32 . encode ( "drep" , words ) ;
40- }
41- if ( rawSearchPhrase . startsWith ( "drep" ) ) {
42- const decodedIdentifier = decodeCIP129Identifier ( rawSearchPhrase ) ;
43- if ( decodedIdentifier ) {
44- const isCIP129Identifier = decodedIdentifier . txID . startsWith ( "22" ) ;
45- if ( isCIP129Identifier ) {
46- return encodeCIP129Identifier ( {
47- txID : decodedIdentifier . txID . slice ( 2 ) ,
48- bech32Prefix : "drep" ,
49- } ) ;
50- }
51- return encodeCIP129Identifier ( {
52- txID : decodedIdentifier . txID ,
53- bech32Prefix : "drep" ,
54- } ) ;
55- }
56- }
57- return rawSearchPhrase ;
58- } catch ( e ) {
59- return rawSearchPhrase ;
60- }
61- } ;
62-
63- const searchPhrase = await searchPhraseProcessor ( ) ;
28+ const searchPhrase = await dRepSearchPhraseProcessor ( rawSearchPhrase ) ;
6429
6530 const response = await API . get < Infinite < DrepDataDTO > > ( "/drep/list" , {
6631 params : {
0 commit comments