Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
3cc098e9
Commit
3cc098e9
authored
Feb 16, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove link
parent
75aca5c0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
225 deletions
+22
-225
redirects.js
configs/nextjs/redirects.js
+22
-24
link.ts
lib/link/link.ts
+0
-41
paths.json
lib/link/paths.json
+0
-26
routes.ts
lib/link/routes.ts
+0
-134
No files found.
configs/nextjs/redirects.js
View file @
3cc098e9
const
PATHS
=
require
(
'
../../lib/link/paths.json
'
);
const
oldUrls
=
[
const
oldUrls
=
[
{
{
oldPath
:
'
/account/tag_transaction
'
,
oldPath
:
'
/account/tag_transaction
'
,
newPath
:
`
${
PATHS
.
private_tags
}
?tab=tx`
,
newPath
:
'
/account/tag_address?tab=tx
'
,
},
},
{
{
oldPath
:
'
/pending-transactions
'
,
oldPath
:
'
/pending-transactions
'
,
newPath
:
`
${
PATHS
.
txs
}
?tab=pending`
,
newPath
:
'
/txs?tab=pending
'
,
},
},
{
{
oldPath
:
'
/tx/:hash/internal-transactions
'
,
oldPath
:
'
/tx/:hash/internal-transactions
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=internal`
,
newPath
:
'
/tx/:hash?tab=internal
'
,
},
},
{
{
oldPath
:
'
/tx/:hash/logs
'
,
oldPath
:
'
/tx/:hash/logs
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=logs`
,
newPath
:
'
/tx/:hash?tab=logs
'
,
},
},
{
{
oldPath
:
'
/tx/:hash/raw-trace
'
,
oldPath
:
'
/tx/:hash/raw-trace
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=raw_trace`
,
newPath
:
'
/tx/:hash?tab=raw_trace
'
,
},
},
{
{
oldPath
:
'
/tx/:hash/state
'
,
oldPath
:
'
/tx/:hash/state
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=state`
,
newPath
:
'
/tx/:hash?tab=state
'
,
},
},
{
{
oldPath
:
'
/uncles
'
,
oldPath
:
'
/uncles
'
,
newPath
:
`
${
PATHS
.
blocks
}
?tab=uncles`
,
newPath
:
'
/blocks?tab=uncles
'
,
},
},
{
{
oldPath
:
'
/reorgs
'
,
oldPath
:
'
/reorgs
'
,
newPath
:
`
${
PATHS
.
blocks
}
?tab=reorgs`
,
newPath
:
'
/blocks?tab=reorgs
'
,
},
},
{
{
oldPath
:
'
/block/:height/transactions
'
,
oldPath
:
'
/block/:height/transactions
'
,
newPath
:
`
${
PATHS
.
block
}
?tab=txs`
,
newPath
:
'
/block/:height?tab=txs
'
,
},
},
{
{
oldPath
:
'
/address/:hash/transactions
'
,
oldPath
:
'
/address/:hash/transactions
'
,
newPath
:
`
${
PATHS
.
address_index
}
`
,
newPath
:
'
/address/:hash
'
,
},
},
{
{
oldPath
:
'
/address/:hash/token-transfers
'
,
oldPath
:
'
/address/:hash/token-transfers
'
,
newPath
:
`
${
PATHS
.
address_index
}
?tab=token_transfers`
,
newPath
:
'
/address/:hash?tab=token_transfers
'
,
},
},
{
{
oldPath
:
'
/address/:hash/tokens
'
,
oldPath
:
'
/address/:hash/tokens
'
,
newPath
:
`
${
PATHS
.
address_index
}
?tab=tokens`
,
newPath
:
'
/address/:hash?tab=tokens
'
,
},
},
{
{
oldPath
:
'
/address/:hash/internal-transactions
'
,
oldPath
:
'
/address/:hash/internal-transactions
'
,
newPath
:
`
${
PATHS
.
address_index
}
?tab=internal_txns`
,
newPath
:
'
/address/:hash?tab=internal_txns
'
,
},
},
{
{
oldPath
:
'
/address/:hash/coin-balances
'
,
oldPath
:
'
/address/:hash/coin-balances
'
,
newPath
:
`
${
PATHS
.
address_index
}
?tab=coin_balance_history`
,
newPath
:
'
/address/:hash?tab=coin_balance_history
'
,
},
},
{
{
oldPath
:
'
/address/:hash/validations
'
,
oldPath
:
'
/address/:hash/validations
'
,
newPath
:
`
${
PATHS
.
address_index
}
?tab=blocks_validated`
,
newPath
:
'
/address/:hash?tab=blocks_validated
'
,
},
},
{
{
oldPath
:
'
/address/:hash/tokens/:token_hash/token-transfers
'
,
oldPath
:
'
/address/:hash/tokens/:token_hash/token-transfers
'
,
newPath
:
`
${
PATHS
.
address_index
}
?tab=token_transfers&token=:token_hash`
,
newPath
:
'
/address/:hash?tab=token_transfers&token=:token_hash
'
,
},
},
// contract verification
// contract verification
{
{
oldPath
:
'
/address/:hash/contract_verifications/new
'
,
oldPath
:
'
/address/:hash/contract_verifications/new
'
,
newPath
:
`
${
PATHS
.
address_contract_verification
}
`
,
newPath
:
'
/address/:hash/contract_verification
'
,
},
},
{
{
oldPath
:
'
/address/:hash/verify-via-flattened-code/new
'
,
oldPath
:
'
/address/:hash/verify-via-flattened-code/new
'
,
newPath
:
`
${
PATHS
.
address_contract_verification
}
?method=flatten_source_code`
,
newPath
:
'
/address/:hash/contract_verification?method=flatten_source_code
'
,
},
},
{
{
oldPath
:
'
/address/:hash/verify-via-standard-json-input/new
'
,
oldPath
:
'
/address/:hash/verify-via-standard-json-input/new
'
,
newPath
:
`
${
PATHS
.
address_contract_verification
}
?method=standard_input`
,
newPath
:
'
/address/:hash/contract_verification?method=standard_input
'
,
},
},
{
{
oldPath
:
'
/address/:hash/verify-via-metadata-json/new
'
,
oldPath
:
'
/address/:hash/verify-via-metadata-json/new
'
,
newPath
:
`
${
PATHS
.
address_contract_verification
}
?method=sourcify`
,
newPath
:
'
/address/:hash/contract_verification?method=sourcify
'
,
},
},
{
{
oldPath
:
'
/address/:hash/verify-via-multi-part-files/new
'
,
oldPath
:
'
/address/:hash/verify-via-multi-part-files/new
'
,
newPath
:
`
${
PATHS
.
address_contract_verification
}
?method=multi_part_file`
,
newPath
:
'
/address/:hash/contract_verification?method=multi_part_file
'
,
},
},
{
{
oldPath
:
'
/address/:hash/verify-vyper-contract/new
'
,
oldPath
:
'
/address/:hash/verify-vyper-contract/new
'
,
newPath
:
`
${
PATHS
.
address_contract_verification
}
?method=vyper_contract`
,
newPath
:
'
/address/:hash/contract_verification?method=vyper_contract
'
,
},
},
];
];
...
...
lib/link/link.ts
deleted
100644 → 0
View file @
75aca5c0
import
appConfig
from
'
configs/app/config
'
;
import
{
ROUTES
}
from
'
./routes
'
;
import
type
{
RouteName
}
from
'
./routes
'
;
const
PATH_PARAM_REGEXP
=
/
\/
:
(\w
+
)
/g
;
/**
* @deprecated Please consider to use "import { route } from 'nextjs-routes';" instead
*/
export
default
function
link
(
routeName
:
RouteName
,
urlParams
?:
Record
<
string
,
Array
<
string
>
|
string
|
undefined
>
,
queryParams
?:
Record
<
string
,
string
>
,
):
string
{
const
route
=
ROUTES
[
routeName
];
if
(
!
route
)
{
return
''
;
}
const
path
=
route
.
pattern
.
replace
(
PATH_PARAM_REGEXP
,
(
_
,
paramName
:
string
)
=>
{
let
paramValue
=
urlParams
?.[
paramName
];
if
(
Array
.
isArray
(
paramValue
))
{
// FIXME we don't have yet params as array, but typescript says that we could
// dunno know how to manage it, fix me if you find an issue
paramValue
=
paramValue
.
join
(
'
,
'
);
}
return
paramValue
?
`/
${
paramValue
}
`
:
''
;
});
// const baseUrl = routeName === 'auth' ? appConfig.authUrl : appConfig.baseUrl;
const
baseUrl
=
appConfig
.
baseUrl
;
const
url
=
new
URL
(
path
,
baseUrl
);
queryParams
&&
Object
.
entries
(
queryParams
).
forEach
(([
key
,
value
])
=>
{
url
.
searchParams
.
append
(
key
,
value
);
});
return
url
.
toString
();
}
lib/link/paths.json
deleted
100644 → 0
View file @
75aca5c0
{
"network_index"
:
"/"
,
"watchlist"
:
"/account/watchlist"
,
"private_tags"
:
"/account/tag_address"
,
"public_tags"
:
"/account/public_tags_request"
,
"api_keys"
:
"/account/api_key"
,
"custom_abi"
:
"/account/custom_abi"
,
"profile"
:
"/auth/profile"
,
"txs"
:
"/txs"
,
"tx"
:
"/tx/:hash"
,
"blocks"
:
"/blocks"
,
"block"
:
"/block/:height"
,
"tokens"
:
"/tokens"
,
"token_index"
:
"/token/:hash"
,
"token_instance_item"
:
"/token/:hash/instance/:id"
,
"address_index"
:
"/address/:hash"
,
"address_contract_verification"
:
"/address/:hash/contract_verification"
,
"accounts"
:
"/accounts"
,
"apps"
:
"/apps"
,
"app_index"
:
"/apps/:id"
,
"search_results"
:
"/search-results"
,
"auth"
:
"/auth/auth0"
,
"stats"
:
"/stats"
,
"visualize_sol2uml"
:
"/visualize/sol2uml"
,
"csv_export"
:
"/csv-export"
}
lib/link/routes.ts
deleted
100644 → 0
View file @
75aca5c0
import
appConfig
from
'
configs/app/config
'
;
// import PATHS from './paths.json';
export
interface
Route
{
pattern
:
string
;
crossNetworkNavigation
?:
boolean
;
// route will not change when switching networks
}
export
type
RouteName
=
keyof
typeof
ROUTES
;
export
const
ROUTES
=
{
// NETWORK MAIN PAGE
// network_index: {
// pattern: PATHS.network_index,
// crossNetworkNavigation: true,
// },
// ACCOUNT
// watchlist: {
// pattern: PATHS.watchlist,
// },
// private_tags: {
// pattern: PATHS.private_tags,
// },
// public_tags: {
// pattern: PATHS.public_tags,
// },
// api_keys: {
// pattern: PATHS.api_keys,
// },
// custom_abi: {
// pattern: PATHS.custom_abi,
// },
// profile: {
// pattern: PATHS.profile,
// },
// TRANSACTIONS
// txs: {
// pattern: PATHS.txs,
// crossNetworkNavigation: true,
// },
// tx: {
// pattern: PATHS.tx,
// },
// BLOCKS
// blocks: {
// pattern: PATHS.blocks,
// crossNetworkNavigation: true,
// },
// block: {
// pattern: PATHS.block,
// },
// TOKENS
// tokens: {
// pattern: PATHS.tokens,
// crossNetworkNavigation: true,
// },
// token_index: {
// pattern: PATHS.token_index,
// crossNetworkNavigation: true,
// },
// token_instance_item: {
// pattern: PATHS.token_instance_item,
// },
// ADDRESSES
// address_index: {
// pattern: PATHS.address_index,
// crossNetworkNavigation: true,
// },
// address_contract_verification: {
// pattern: PATHS.address_contract_verification,
// crossNetworkNavigation: true,
// },
// ACCOUNTS
// accounts: {
// pattern: PATHS.accounts,
// crossNetworkNavigation: true,
// },
// APPS
// apps: {
// pattern: PATHS.apps,
// },
// app_index: {
// pattern: PATHS.app_index,
// },
// stats: {
// pattern: PATHS.stats,
// },
// SEARCH
// search_results: {
// pattern: PATHS.search_results,
// },
// VISUALIZE
// visualize_sol2uml: {
// pattern: PATHS.visualize_sol2uml,
// },
// csv_export: {
// pattern: PATHS.csv_export,
// },
// AUTH
// todo_tom need add page to the app
// auth: {
// pattern: PATHS.auth,
// },
};
// !!! for development purpose only !!!
// don't wanna strict ROUTES to type "Record<string, Route>"
// otherwise we lose benefit of using "keyof typeof ROUTES" for possible route names (it will be any string then)
// but we still want typescript to tell us if routes follow its interface
// so we do this simple type-checking here
//
// another option is to create common enum with all possible route names and use it across the project
// but it is a little bit overwhelming as it seems right now
function
checkRoutes
(
route
:
Record
<
string
,
Route
>
)
{
return
route
;
}
if
(
appConfig
.
isDev
)
{
checkRoutes
(
ROUTES
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment