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
09c79f4a
Commit
09c79f4a
authored
Sep 06, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring
parent
2fd25692
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
39 additions
and
26 deletions
+39
-26
getCspPolicy.js
lib/csp/getCspPolicy.js
+2
-2
availableNetworks.ts
lib/networks/availableNetworks.ts
+6
-13
getAvailablePaths.ts
lib/networks/getAvailablePaths.ts
+5
-0
isAccountRoute.ts
lib/networks/isAccountRoute.ts
+5
-0
parseNetworkConfig.js
lib/networks/parseNetworkConfig.js
+10
-0
api_key.tsx
pages/[network_type]/[network_sub_type]/account/api_key.tsx
+1
-1
custom_abi.tsx
.../[network_type]/[network_sub_type]/account/custom_abi.tsx
+1
-1
public_tags_request.tsx
..._type]/[network_sub_type]/account/public_tags_request.tsx
+1
-1
tag_address.tsx
...[network_type]/[network_sub_type]/account/tag_address.tsx
+1
-1
tag_transaction.tsx
...work_type]/[network_sub_type]/account/tag_transaction.tsx
+1
-1
watchlist.tsx
...s/[network_type]/[network_sub_type]/account/watchlist.tsx
+1
-1
profile.tsx
pages/[network_type]/[network_sub_type]/auth/profile.tsx
+1
-1
index.tsx
pages/[network_type]/[network_sub_type]/index.tsx
+1
-1
NetworkMenuContentDesktop.tsx
ui/blocks/networkMenu/NetworkMenuContentDesktop.tsx
+1
-1
NetworkMenuContentMobile.tsx
ui/blocks/networkMenu/NetworkMenuContentMobile.tsx
+1
-1
NetworkMenuLink.tsx
ui/blocks/networkMenu/NetworkMenuLink.tsx
+1
-1
No files found.
lib/csp/getCspPolicy.js
View file @
09c79f4a
const
getSupportedNetworks
=
require
(
'
../networks/getSupportedNetworks
'
);
const
parseNetworkConfig
=
require
(
'
../networks/parseNetworkConfig
'
);
const
KEY_WORDS
=
{
BLOB
:
'
blob:
'
,
...
...
@@ -16,7 +16,7 @@ const MAIN_DOMAINS = [ '*.blockscout.com', 'blockscout.com' ];
const
isDev
=
process
.
env
.
NODE_ENV
===
'
development
'
;
function
getNetworksExternalAssets
()
{
const
icons
=
getSupportedNetworks
()
const
icons
=
parseNetworkConfig
()
.
filter
(({
icon
})
=>
typeof
icon
===
'
string
'
)
.
map
(({
icon
})
=>
new
URL
(
icon
));
...
...
lib/networks.ts
→
lib/networks
/availableNetworks
.ts
View file @
09c79f4a
...
...
@@ -9,7 +9,8 @@ import optimismIcon from 'icons/networks/optimism.svg';
import
poaSokolIcon
from
'
icons/networks/poa-sokol.svg
'
;
import
poaIcon
from
'
icons/networks/poa.svg
'
;
import
rskIcon
from
'
icons/networks/rsk.svg
'
;
import
getSupportedNetworks
from
'
lib/networks/getSupportedNetworks
'
;
import
parseNetworkConfig
from
'
./parseNetworkConfig
'
;
// will change later when we agree how to host network icons
const
ICONS
:
Record
<
string
,
React
.
FunctionComponent
<
React
.
SVGAttributes
<
SVGElement
>>>
=
{
...
...
@@ -25,11 +26,13 @@ const ICONS: Record<string, React.FunctionComponent<React.SVGAttributes<SVGEleme
'
artis/sigma1
'
:
artisIcon
,
};
export
const
NETWORKS
:
Array
<
Network
>
=
(()
=>
{
const
networksFromConfig
:
Array
<
Network
>
=
getSupportedNetworks
();
const
NETWORKS
:
Array
<
Network
>
=
(()
=>
{
const
networksFromConfig
:
Array
<
Network
>
=
parseNetworkConfig
();
return
networksFromConfig
.
map
((
network
)
=>
({
...
network
,
icon
:
network
.
icon
||
ICONS
[
`
${
network
.
type
}
/
${
network
.
subType
}
`
]
}));
})();
export
default
NETWORKS
;
// for easy env creation
// const FOR_CONFIG = [
// {
...
...
@@ -102,13 +105,3 @@ export const NETWORKS: Array<Network> = (() => {
// group: 'other',
// },
// ];
export
const
ACCOUNT_ROUTES
=
[
'
/watchlist
'
,
'
/tag_address
'
,
'
/tag_transaction
'
,
'
/public_tags_request
'
,
'
/api_key
'
,
'
/custom_abi
'
];
export
function
isAccountRoute
(
route
:
string
)
{
return
ACCOUNT_ROUTES
.
includes
(
route
);
}
export
function
getAvailablePaths
()
{
return
NETWORKS
.
map
(({
type
,
subType
})
=>
({
params
:
{
network_type
:
type
,
network_sub_type
:
subType
}
}));
}
lib/networks/getAvailablePaths.ts
0 → 100644
View file @
09c79f4a
import
NETWORKS
from
'
./availableNetworks
'
;
export
default
function
getAvailablePaths
()
{
return
NETWORKS
.
map
(({
type
,
subType
})
=>
({
params
:
{
network_type
:
type
,
network_sub_type
:
subType
}
}));
}
lib/networks/isAccountRoute.ts
0 → 100644
View file @
09c79f4a
export
const
ACCOUNT_ROUTES
=
[
'
/watchlist
'
,
'
/tag_address
'
,
'
/tag_transaction
'
,
'
/public_tags_request
'
,
'
/api_key
'
,
'
/custom_abi
'
];
export
default
function
isAccountRoute
(
route
:
string
)
{
return
ACCOUNT_ROUTES
.
includes
(
route
);
}
lib/networks/
getSupportedNetworks
.js
→
lib/networks/
parseNetworkConfig
.js
View file @
09c79f4a
function
getSupportedNetworks
()
{
// should be CommonJS module since it used for next.config.js
function
parseNetworkConfig
()
{
try
{
return
JSON
.
parse
(
process
.
env
.
NEXT_PUBLIC_SUPPORTED_NETWORKS
||
'
[]
'
);
}
catch
(
error
)
{
...
...
@@ -6,4 +7,4 @@ function getSupportedNetworks() {
}
}
module
.
exports
=
getSupportedNetworks
;
module
.
exports
=
parseNetworkConfig
;
pages/[network_type]/[network_sub_type]/account/api_key.tsx
View file @
09c79f4a
...
...
@@ -2,7 +2,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
ApiKeys
from
'
ui/pages/ApiKeys
'
;
const
ApiKeysPage
:
NextPage
=
()
=>
{
...
...
pages/[network_type]/[network_sub_type]/account/custom_abi.tsx
View file @
09c79f4a
...
...
@@ -2,7 +2,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
CustomAbi
from
'
ui/pages/CustomAbi
'
;
const
CustomAbiPage
:
NextPage
=
()
=>
{
...
...
pages/[network_type]/[network_sub_type]/account/public_tags_request.tsx
View file @
09c79f4a
...
...
@@ -2,7 +2,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
PublicTags
from
'
ui/pages/PublicTags
'
;
const
PublicTagsPage
:
NextPage
=
()
=>
{
...
...
pages/[network_type]/[network_sub_type]/account/tag_address.tsx
View file @
09c79f4a
...
...
@@ -2,7 +2,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
PrivateTags
from
'
ui/pages/PrivateTags
'
;
const
AddressTagsPage
:
NextPage
=
()
=>
{
...
...
pages/[network_type]/[network_sub_type]/account/tag_transaction.tsx
View file @
09c79f4a
...
...
@@ -2,7 +2,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
PrivateTags
from
'
ui/pages/PrivateTags
'
;
const
TransactionTagsPage
:
NextPage
=
()
=>
{
...
...
pages/[network_type]/[network_sub_type]/account/watchlist.tsx
View file @
09c79f4a
...
...
@@ -2,7 +2,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
WatchList
from
'
ui/pages/Watchlist
'
;
const
WatchListPage
:
NextPage
=
()
=>
{
...
...
pages/[network_type]/[network_sub_type]/auth/profile.tsx
View file @
09c79f4a
...
...
@@ -2,7 +2,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
MyProfile
from
'
ui/pages/MyProfile
'
;
const
MyProfilePage
:
NextPage
=
()
=>
{
...
...
pages/[network_type]/[network_sub_type]/index.tsx
View file @
09c79f4a
...
...
@@ -3,7 +3,7 @@ import type { NextPage, GetStaticPaths } from 'next';
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
{
getAvailablePaths
}
from
'
lib/network
s
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePath
s
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
const
Home
:
NextPage
=
()
=>
{
...
...
ui/blocks/networkMenu/NetworkMenuContentDesktop.tsx
View file @
09c79f4a
...
...
@@ -4,7 +4,7 @@ import React from 'react';
import
type
{
NetworkGroup
}
from
'
types/networks
'
;
import
{
NETWORKS
}
from
'
lib/n
etworks
'
;
import
NETWORKS
from
'
lib/networks/availableN
etworks
'
;
import
NetworkMenuLink
from
'
./NetworkMenuLink
'
;
...
...
ui/blocks/networkMenu/NetworkMenuContentMobile.tsx
View file @
09c79f4a
...
...
@@ -5,7 +5,7 @@ import React from 'react';
import
type
{
NetworkGroup
}
from
'
types/networks
'
;
import
{
NETWORKS
}
from
'
lib/n
etworks
'
;
import
NETWORKS
from
'
lib/networks/availableN
etworks
'
;
import
NetworkMenuLink
from
'
./NetworkMenuLink
'
;
...
...
ui/blocks/networkMenu/NetworkMenuLink.tsx
View file @
09c79f4a
...
...
@@ -6,7 +6,7 @@ import type { Network } from 'types/networks';
import
checkIcon
from
'
icons/check.svg
'
;
import
placeholderIcon
from
'
icons/networks/placeholder.svg
'
;
import
{
isAccountRoute
}
from
'
lib/networks
'
;
import
isAccountRoute
from
'
lib/networks/isAccountRoute
'
;
import
useColors
from
'
./useColors
'
;
...
...
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