Commit 15bb8d9a authored by tom's avatar tom

fix ts

parent 482bd44e
...@@ -3,8 +3,6 @@ import type { WalletType } from 'types/client/wallets'; ...@@ -3,8 +3,6 @@ import type { WalletType } from 'types/client/wallets';
import type { NetworkExplorer } from 'types/networks'; import type { NetworkExplorer } from 'types/networks';
import type { ChainIndicatorId } from 'ui/home/indicators/types'; import type { ChainIndicatorId } from 'ui/home/indicators/types';
import { SUPPORTED_WALLETS } from 'lib/web3/wallets';
const getEnvValue = (env: string | undefined) => env?.replaceAll('\'', '"'); const getEnvValue = (env: string | undefined) => env?.replaceAll('\'', '"');
const parseEnvJson = <DataType>(env: string | undefined): DataType | null => { const parseEnvJson = <DataType>(env: string | undefined): DataType | null => {
try { try {
...@@ -16,6 +14,11 @@ const parseEnvJson = <DataType>(env: string | undefined): DataType | null => { ...@@ -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 stripTrailingSlash = (str: string) => str[str.length - 1] === '/' ? str.slice(0, -1) : str;
const getWeb3DefaultWallet = (): WalletType => { const getWeb3DefaultWallet = (): WalletType => {
const envValue = getEnvValue(process.env.NEXT_PUBLIC_WEB3_DEFAULT_WALLET); 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; return (envValue && SUPPORTED_WALLETS.includes(envValue) ? envValue : 'metamask') as WalletType;
}; };
......
export const SUPPORTED_WALLETS = [ import type { WalletType, WalletInfo } from 'types/client/wallets';
'metamask' as const,
'coinbase' as const,
];
import coinbaseIcon from 'icons/wallets/coinbase.svg'; import coinbaseIcon from 'icons/wallets/coinbase.svg';
import metamaskIcon from 'icons/wallets/metamask.svg'; import metamaskIcon from 'icons/wallets/metamask.svg';
export const WALLETS_INFO = { export const WALLETS_INFO: Record<WalletType, WalletInfo> = {
metamask: { metamask: {
add_token_text: 'Add token to MetaMask', add_token_text: 'Add token to MetaMask',
add_network_text: 'Add network to MetaMask', add_network_text: 'Add network to MetaMask',
......
import type { providers } from 'ethers'; 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 interface WalletInfo {
add_token_text: string;
export type WalletType = ArrayElement<typeof SUPPORTED_WALLETS>; add_network_text: string;
icon: React.ElementType;
}
export interface ExternalProvider extends providers.ExternalProvider { export interface ExternalProvider extends providers.ExternalProvider {
isCoinbaseWallet?: boolean; isCoinbaseWallet?: boolean;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment