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
15bb8d9a
Commit
15bb8d9a
authored
Apr 25, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ts
parent
482bd44e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
config.ts
configs/app/config.ts
+5
-2
wallets.ts
lib/web3/wallets.ts
+2
-5
wallets.ts
types/client/wallets.ts
+6
-4
No files found.
configs/app/config.ts
View file @
15bb8d9a
...
...
@@ -3,8 +3,6 @@ import type { WalletType } from 'types/client/wallets';
import
type
{
NetworkExplorer
}
from
'
types/networks
'
;
import
type
{
ChainIndicatorId
}
from
'
ui/home/indicators/types
'
;
import
{
SUPPORTED_WALLETS
}
from
'
lib/web3/wallets
'
;
const
getEnvValue
=
(
env
:
string
|
undefined
)
=>
env
?.
replaceAll
(
'
\'
'
,
'
"
'
);
const
parseEnvJson
=
<
DataType
>
(
env
:
string
|
undefined
):
DataType
|
null
=>
{
try
{
...
...
@@ -16,6 +14,11 @@ const parseEnvJson = <DataType>(env: string | undefined): DataType | null => {
const
stripTrailingSlash
=
(
str
:
string
)
=>
str
[
str
.
length
-
1
]
===
'
/
'
?
str
.
slice
(
0
,
-
1
)
:
str
;
const
getWeb3DefaultWallet
=
():
WalletType
=>
{
const
envValue
=
getEnvValue
(
process
.
env
.
NEXT_PUBLIC_WEB3_DEFAULT_WALLET
);
const
SUPPORTED_WALLETS
:
Array
<
WalletType
>
=
[
'
metamask
'
,
'
coinbase
'
,
];
return
(
envValue
&&
SUPPORTED_WALLETS
.
includes
(
envValue
)
?
envValue
:
'
metamask
'
)
as
WalletType
;
};
...
...
lib/web3/wallets.ts
View file @
15bb8d9a
export
const
SUPPORTED_WALLETS
=
[
'
metamask
'
as
const
,
'
coinbase
'
as
const
,
];
import
type
{
WalletType
,
WalletInfo
}
from
'
types/client/wallets
'
;
import
coinbaseIcon
from
'
icons/wallets/coinbase.svg
'
;
import
metamaskIcon
from
'
icons/wallets/metamask.svg
'
;
export
const
WALLETS_INFO
=
{
export
const
WALLETS_INFO
:
Record
<
WalletType
,
WalletInfo
>
=
{
metamask
:
{
add_token_text
:
'
Add token to MetaMask
'
,
add_network_text
:
'
Add network to MetaMask
'
,
...
...
types/client/wallets.ts
View file @
15bb8d9a
import
type
{
providers
}
from
'
ethers
'
;
import
type
{
ArrayElement
}
from
'
types/utils
'
;
export
type
WalletType
=
'
metamask
'
|
'
coinbase
'
;
import
type
{
SUPPORTED_WALLETS
}
from
'
lib/web3/wallets
'
;
export
type
WalletType
=
ArrayElement
<
typeof
SUPPORTED_WALLETS
>
;
export
interface
WalletInfo
{
add_token_text
:
string
;
add_network_text
:
string
;
icon
:
React
.
ElementType
;
}
export
interface
ExternalProvider
extends
providers
.
ExternalProvider
{
isCoinbaseWallet
?:
boolean
;
...
...
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