@@ -59,38 +59,34 @@ export abstract class RouteUtils {
5959 } ,
6060 } satisfies Record < Network , Record < Layer , boolean > >
6161
62- static getDashboardRoute = ( { network, layer } : SearchScope ) => {
62+ static getScopeRoute = ( { network, layer } : SearchScope ) => {
6363 return `/${ encodeURIComponent ( network ) } /${ encodeURIComponent ( layer ) } `
6464 }
6565
66- static getLatestTransactionsRoute = ( { network, layer } : SearchScope ) => {
67- return `/${ encodeURIComponent ( network ) } /${ encodeURIComponent ( layer ) } /tx`
66+ static getDashboardRoute = ( scope : SearchScope ) => this . getScopeRoute ( scope )
67+
68+ static getLatestTransactionsRoute = ( scope : SearchScope ) => {
69+ return `${ this . getScopeRoute ( scope ) } /tx`
6870 }
6971
70- static getTopTokensRoute = ( { network , layer } : SearchScope ) => {
71- return `/ ${ encodeURIComponent ( network ) } / ${ encodeURIComponent ( layer ) } /token`
72+ static getTopTokensRoute = ( scope : SearchScope ) => {
73+ return `${ this . getScopeRoute ( scope ) } /token`
7274 }
7375
74- static getLatestBlocksRoute = ( { network , layer } : SearchScope ) => {
75- return `/ ${ encodeURIComponent ( network ) } / ${ encodeURIComponent ( layer ) } /block`
76+ static getLatestBlocksRoute = ( scope : SearchScope ) => {
77+ return `${ this . getScopeRoute ( scope ) } /block`
7678 }
7779
78- static getBlockRoute = ( { network, layer } : SearchScope , blockHeight : number ) => {
79- return `/${ encodeURIComponent ( network ) } /${ encodeURIComponent ( layer ) } /block/${ encodeURIComponent (
80- blockHeight ,
81- ) } `
80+ static getBlockRoute = ( scope : SearchScope , blockHeight : number ) => {
81+ return `${ this . getScopeRoute ( scope ) } /block/${ encodeURIComponent ( blockHeight ) } `
8282 }
8383
8484 static getTransactionRoute = ( scope : SearchScope , txHash : string ) => {
85- return `/${ encodeURIComponent ( scope . network ) } /${ encodeURIComponent ( scope . layer ) } /tx/${ encodeURIComponent (
86- txHash ,
87- ) } `
85+ return `${ this . getScopeRoute ( scope ) } /tx/${ encodeURIComponent ( txHash ) } `
8886 }
8987
90- static getAccountRoute = ( { network, layer } : SearchScope , account : string ) => {
91- return `/${ encodeURIComponent ( network ) } /${ encodeURIComponent ( layer ) } /address/${ encodeURIComponent (
92- account ,
93- ) } `
88+ static getAccountRoute = ( scope : SearchScope , accountAddress : string ) => {
89+ return `${ this . getScopeRoute ( scope ) } /address/${ encodeURIComponent ( accountAddress ) } `
9490 }
9591
9692 static getAccountsRoute = ( network : Network ) => {
@@ -122,28 +118,20 @@ export abstract class RouteUtils {
122118
123119 static getSearchRoute = ( scope : SearchScope | undefined , searchTerm : string ) => {
124120 return scope
125- ? `/ ${ encodeURIComponent ( scope . network ) } / ${ encodeURIComponent ( scope . layer ) } /search?q=${ encodeURIComponent ( searchTerm ) } `
121+ ? `${ this . getScopeRoute ( scope ) } /search?q=${ encodeURIComponent ( searchTerm ) } `
126122 : `/search?q=${ encodeURIComponent ( searchTerm ) } `
127123 }
128124
129- static getTokenRoute = ( { network, layer } : SearchScope , tokenAddress : string ) => {
130- return `/${ encodeURIComponent ( network ) } /${ encodeURIComponent ( layer ) } /token/${ encodeURIComponent (
131- tokenAddress ,
132- ) } `
125+ static getTokenRoute = ( scope : SearchScope , tokenAddress : string ) => {
126+ return `${ this . getScopeRoute ( scope ) } /token/${ encodeURIComponent ( tokenAddress ) } `
133127 }
134128
135- static getTokenHoldersRoute = ( { network, layer } : SearchScope , tokenAddress : string ) => {
136- return `/${ encodeURIComponent ( network ) } /${ encodeURIComponent ( layer ) } /token/${ encodeURIComponent (
137- tokenAddress ,
138- ) } /holders`
129+ static getTokenHoldersRoute = ( scope : SearchScope , tokenAddress : string ) => {
130+ return `${ this . getScopeRoute ( scope ) } /token/${ encodeURIComponent ( tokenAddress ) } /holders`
139131 }
140132
141- static getNFTInstanceRoute = (
142- { network, layer } : SearchScope ,
143- contractAddress : string ,
144- instanceId : string ,
145- ) : string =>
146- `/${ encodeURIComponent ( network ) } /${ encodeURIComponent ( layer ) } /token/${ encodeURIComponent (
133+ static getNFTInstanceRoute = ( scope : SearchScope , contractAddress : string , instanceId : string ) : string =>
134+ `${ this . getScopeRoute ( scope ) } /token/${ encodeURIComponent (
147135 contractAddress ,
148136 ) } /instance/${ encodeURIComponent ( instanceId ) } `
149137
0 commit comments