@web3jskit/walletkit 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +6 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -3
- package/src/assets/svg/dataBase.ts +0 -11
- package/src/assets/svg/metaMaskWallet.ts +0 -35
- package/src/components/ConnectButton/ConnectedInfo.tsx +0 -17
- package/src/components/ConnectButton/index.tsx +0 -48
- package/src/components/Connecting/index.tsx +0 -26
- package/src/components/Connecting/style.ts +0 -53
- package/src/components/GetWallet/index.tsx +0 -82
- package/src/components/GetWallet/style.ts +0 -118
- package/src/components/Header/ModalHeader.tsx +0 -24
- package/src/components/Header/style.ts +0 -74
- package/src/components/Icon/index.tsx +0 -120
- package/src/components/Introduce/index.tsx +0 -30
- package/src/components/Introduce/style.ts +0 -73
- package/src/components/Modal/ConnectModal.tsx +0 -155
- package/src/components/Modal/WalletInfoModal.tsx +0 -82
- package/src/components/Modal/index.tsx +0 -80
- package/src/components/Modal/style.ts +0 -190
- package/src/components/SVGs/backArrowSvg.tsx +0 -10
- package/src/components/SVGs/closeSvg.tsx +0 -11
- package/src/components/SVGs/copiedSvg.tsx +0 -11
- package/src/components/SVGs/copySvg.tsx +0 -11
- package/src/components/SVGs/exitSvg.tsx +0 -11
- package/src/components/SVGs/spinSvg.tsx +0 -10
- package/src/components/Text/index.tsx +0 -67
- package/src/components/WalletKitProvider/ChainProvider.tsx +0 -34
- package/src/components/WalletKitProvider/I18nProvider.tsx +0 -52
- package/src/components/WalletKitProvider/ThemeProvider.tsx +0 -16
- package/src/components/WalletKitProvider/index.tsx +0 -40
- package/src/components/WalletList/index.tsx +0 -42
- package/src/components/WalletList/style.ts +0 -102
- package/src/components/WalletTriggerButton/index.tsx +0 -50
- package/src/components/WalletTriggerButton/style.ts +0 -53
- package/src/default.d.ts +0 -18
- package/src/hooks/useWalletKit.ts +0 -42
- package/src/index.ts +0 -9
- package/src/locals/i18n.ts +0 -19
- package/src/locals/languages/en.json +0 -30
- package/src/locals/languages/zh.json +0 -30
- package/src/locals/resources.ts +0 -11
- package/src/stores/SlotsWalletStore.ts +0 -48
- package/src/stores/index.ts +0 -75
- package/src/styled/index.ts +0 -79
- package/src/test/getwalletprovider.test.ts +0 -9
- package/src/test/setup.ts +0 -7
- package/src/theme/index.ts +0 -93
- package/src/theme/styled.d.ts +0 -30
- package/src/types/configType.ts +0 -2
- package/src/types/slotsType.ts +0 -23
- package/src/utils/formatter.ts +0 -4
- package/src/utils/generateAvatar.ts +0 -35
- package/src/wallets/GelWallet/index.ts +0 -0
- package/src/wallets/SlotsWallets/index.ts +0 -30
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -55
- package/vitest.config.ts +0 -10
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { styled } from 'styled-components';
|
|
3
|
-
|
|
4
|
-
interface TextOrg {
|
|
5
|
-
text?: string | number | any;
|
|
6
|
-
size?: number;
|
|
7
|
-
weight?: number;
|
|
8
|
-
color?: string;
|
|
9
|
-
padding?: string;
|
|
10
|
-
margin?: string;
|
|
11
|
-
ellipsis?: boolean;
|
|
12
|
-
className?: string;
|
|
13
|
-
children?: React.ReactNode;
|
|
14
|
-
prefix?: string;
|
|
15
|
-
suffix?: string;
|
|
16
|
-
counting?: boolean;
|
|
17
|
-
href?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const TextStyled = styled.div`
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
|
|
24
|
-
.text {
|
|
25
|
-
max-width: 120px;
|
|
26
|
-
color: ${({ theme }) => theme.textColor2};
|
|
27
|
-
font-family: 'Manrope';
|
|
28
|
-
white-space: nowrap;
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
text-overflow: ellipsis;
|
|
31
|
-
|
|
32
|
-
@media (max-width: 768px) {
|
|
33
|
-
white-space: wrap;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
export const Text: React.FC<TextOrg> = ({
|
|
39
|
-
prefix,
|
|
40
|
-
suffix,
|
|
41
|
-
className = '',
|
|
42
|
-
text,
|
|
43
|
-
size,
|
|
44
|
-
weight,
|
|
45
|
-
color,
|
|
46
|
-
padding = '',
|
|
47
|
-
margin = ''
|
|
48
|
-
}) => {
|
|
49
|
-
return (
|
|
50
|
-
<TextStyled
|
|
51
|
-
className={className}
|
|
52
|
-
style={{
|
|
53
|
-
fontSize: size ? size + 'px' : '16px',
|
|
54
|
-
fontWeight: weight || 700,
|
|
55
|
-
color,
|
|
56
|
-
padding,
|
|
57
|
-
margin
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
{prefix ? <span>{prefix}</span> : <></>}
|
|
61
|
-
<span className="text" dangerouslySetInnerHTML={{ __html: text }} />
|
|
62
|
-
{suffix ? <span>{suffix}</span> : <></>}
|
|
63
|
-
</TextStyled>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default Text;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { createContext, type ReactNode, useContext, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
interface IChainProvider {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
defaultChain?: number | any;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface ChainContextValue {
|
|
9
|
-
chains: any[];
|
|
10
|
-
defaultChainId?: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const ChainContext = createContext<ChainContextValue>({
|
|
14
|
-
chains: []
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export function ChainProvider({ children, defaultChain }: IChainProvider) {
|
|
18
|
-
const chainValue = useMemo(() => {
|
|
19
|
-
return {
|
|
20
|
-
chains: [],
|
|
21
|
-
defaultChainId: typeof defaultChain === 'number' ? defaultChain : defaultChain?.id
|
|
22
|
-
};
|
|
23
|
-
}, [defaultChain]);
|
|
24
|
-
|
|
25
|
-
return <ChainContext.Provider value={chainValue}>{children}</ChainContext.Provider>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const useWalletKitChains = () => {
|
|
29
|
-
return useContext(ChainContext).chains;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const useWalletKitDefaultChainId = () => {
|
|
33
|
-
return useContext(ChainContext).defaultChainId;
|
|
34
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { createContext, type ReactNode, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { type Locals } from '../../types/configType';
|
|
3
|
-
import i18n from '../../locals/i18n';
|
|
4
|
-
|
|
5
|
-
interface I18nProviderProps {
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
language?: Locals;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const detectedBrowserLocale = () => {
|
|
11
|
-
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
|
|
12
|
-
if (navigator.languages?.length) {
|
|
13
|
-
return navigator.languages[0];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (navigator.language) {
|
|
17
|
-
return navigator.language;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return '';
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const I18nContext = createContext<{ i18n: typeof i18n }>({ i18n });
|
|
24
|
-
|
|
25
|
-
export const I18nProvider = ({ children, language }: I18nProviderProps) => {
|
|
26
|
-
const [updateCount, setUpdateCount] = useState(0);
|
|
27
|
-
|
|
28
|
-
const browserLocale: Locals = useMemo(() => {
|
|
29
|
-
return detectedBrowserLocale() as Locals;
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
i18n.on('languageChanged', () => {
|
|
34
|
-
setUpdateCount(count => count + 1);
|
|
35
|
-
});
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (language && language !== i18n.language) {
|
|
40
|
-
i18n.changeLanguage(language);
|
|
41
|
-
} else if (!language && browserLocale && browserLocale !== i18n.language) {
|
|
42
|
-
i18n.changeLanguage(browserLocale);
|
|
43
|
-
}
|
|
44
|
-
}, [language, browserLocale]);
|
|
45
|
-
|
|
46
|
-
const memoizedValue = useMemo(() => {
|
|
47
|
-
const t = (key: string, options?: any) => i18n.t(key, options);
|
|
48
|
-
return { t, i18n };
|
|
49
|
-
}, [updateCount]);
|
|
50
|
-
|
|
51
|
-
return <I18nContext.Provider value={memoizedValue}>{children}</I18nContext.Provider>;
|
|
52
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ThemeProvider } from 'styled-components';
|
|
2
|
-
import { type ReactNode, useMemo } from 'react';
|
|
3
|
-
import { type Theme } from '../../types/configType';
|
|
4
|
-
import { themeStyle } from '../../theme';
|
|
5
|
-
|
|
6
|
-
interface IWalletKitThemeProvider {
|
|
7
|
-
theme?: Theme;
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function WalletKitThemeProvider({ theme, children }: IWalletKitThemeProvider) {
|
|
12
|
-
const themeObject = useMemo(() => {
|
|
13
|
-
return themeStyle[theme || 'lightMode'];
|
|
14
|
-
}, [theme]);
|
|
15
|
-
return <ThemeProvider theme={themeObject}>{children}</ThemeProvider>;
|
|
16
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { ChainProvider } from './ChainProvider';
|
|
3
|
-
|
|
4
|
-
import { ConnectModal } from '../Modal/ConnectModal';
|
|
5
|
-
import { walletKitStore, AppModal } from '../../stores';
|
|
6
|
-
import { I18nProvider } from './I18nProvider';
|
|
7
|
-
import type { Locals, Theme } from '../../types/configType';
|
|
8
|
-
import { WalletKitThemeProvider } from './ThemeProvider';
|
|
9
|
-
import { ThemedGlobalStyle } from '../../theme';
|
|
10
|
-
import { WalletInfoModal } from '../Modal/WalletInfoModal';
|
|
11
|
-
|
|
12
|
-
interface IWalletKitProvider {
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
language?: Locals;
|
|
15
|
-
defaultChain?: number | any;
|
|
16
|
-
theme?: Theme;
|
|
17
|
-
connectButtonSlots?: ReactNode[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function WalletKitProvider({ children, language, defaultChain, theme, connectButtonSlots }: IWalletKitProvider) {
|
|
21
|
-
// console.log('theme::', theme);
|
|
22
|
-
// console.log('language::', language);
|
|
23
|
-
// console.log('defaultChain::', defaultChain);
|
|
24
|
-
|
|
25
|
-
const modalType = walletKitStore((state: any) => state.modalType);
|
|
26
|
-
return (
|
|
27
|
-
<>
|
|
28
|
-
<ChainProvider defaultChain={defaultChain}>
|
|
29
|
-
<I18nProvider language={language}>
|
|
30
|
-
<WalletKitThemeProvider theme={theme}>
|
|
31
|
-
<ThemedGlobalStyle />
|
|
32
|
-
<ConnectModal slots={connectButtonSlots} isOpen={modalType === AppModal.ConnectModal} />
|
|
33
|
-
<WalletInfoModal isOpen={modalType === AppModal.InfoModal} />
|
|
34
|
-
<div>{children}</div>
|
|
35
|
-
</WalletKitThemeProvider>
|
|
36
|
-
</I18nProvider>
|
|
37
|
-
</ChainProvider>
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useTranslation } from 'react-i18next';
|
|
2
|
-
import ModalHeader from '../Header/ModalHeader';
|
|
3
|
-
import WalletListContainer from './style';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
|
|
6
|
-
interface WalletListProps {
|
|
7
|
-
list?: any[];
|
|
8
|
-
onBack?: () => void;
|
|
9
|
-
onGetWallet?: (wallet: any) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function WalletList({ list, onBack, onGetWallet }: WalletListProps) {
|
|
13
|
-
const { t } = useTranslation();
|
|
14
|
-
|
|
15
|
-
// random three wallets in the list
|
|
16
|
-
const randomList = useMemo(() => {
|
|
17
|
-
const randomList = list?.sort(() => Math.random() - 0.5).slice(0, 3);
|
|
18
|
-
return randomList;
|
|
19
|
-
}, [list]);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<WalletListContainer>
|
|
23
|
-
<ModalHeader title={t('getWalletTitle')} onBack={onBack} />
|
|
24
|
-
<div className="walletList">
|
|
25
|
-
{randomList?.map((item, index) => (
|
|
26
|
-
<div className="walletItem" key={index + item.name}>
|
|
27
|
-
<img src={item.icon} alt={item.name} />
|
|
28
|
-
<div>
|
|
29
|
-
<div className="name">{item.name}</div>
|
|
30
|
-
{item.name !== 'GelWallet' && <div className="description">{t('getWalletTips')}</div>}
|
|
31
|
-
</div>
|
|
32
|
-
<div className="button" onClick={() => onGetWallet?.(item)}>
|
|
33
|
-
{t('getWallet')}
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
))}
|
|
37
|
-
</div>
|
|
38
|
-
<div className="question">{t('getWalletQuestion')}</div>
|
|
39
|
-
<div className="answer">{t('getWalletAnswer')}</div>
|
|
40
|
-
</WalletListContainer>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { styled } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
const WalletListContainer = styled.div`
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
font-family: Manrope;
|
|
7
|
-
color: ${({ theme }) => theme.textColor1};
|
|
8
|
-
height: 100%;
|
|
9
|
-
|
|
10
|
-
.walletList {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
padding: 10px 20px;
|
|
14
|
-
gap: 20px;
|
|
15
|
-
flex: 1;
|
|
16
|
-
overflow: auto;
|
|
17
|
-
|
|
18
|
-
.walletItem {
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
img {
|
|
24
|
-
width: 28px;
|
|
25
|
-
height: 28px;
|
|
26
|
-
flex-shrink: 0;
|
|
27
|
-
margin-right: 10px;
|
|
28
|
-
border-radius: 6px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.name {
|
|
32
|
-
font-size: 14px;
|
|
33
|
-
font-weight: 700;
|
|
34
|
-
line-height: 14px;
|
|
35
|
-
color: ${({ theme }) => theme.textColor};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.description {
|
|
39
|
-
margin-top: 10px;
|
|
40
|
-
font-size: 12px;
|
|
41
|
-
font-weight: 500;
|
|
42
|
-
line-height: 14px;
|
|
43
|
-
color: ${({ theme }) => theme.textColor3};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.button {
|
|
47
|
-
display: inline-block;
|
|
48
|
-
margin-left: auto;
|
|
49
|
-
padding: 11px 16px;
|
|
50
|
-
color: ${({ theme }) => theme.buttonColor};
|
|
51
|
-
background: ${({ theme }) => theme.buttonBg};
|
|
52
|
-
font-size: 14px;
|
|
53
|
-
font-weight: 700;
|
|
54
|
-
line-height: 14px;
|
|
55
|
-
text-align: center;
|
|
56
|
-
border-radius: 8px;
|
|
57
|
-
box-sizing: border-box;
|
|
58
|
-
cursor: pointer;
|
|
59
|
-
height: 36px;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.question {
|
|
64
|
-
margin-left: 42px;
|
|
65
|
-
margin-bottom: 10px;
|
|
66
|
-
font-size: 16px;
|
|
67
|
-
font-weight: 700;
|
|
68
|
-
line-height: 16px;
|
|
69
|
-
color: ${({ theme }) => theme.textColor4};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.answer {
|
|
73
|
-
margin-left: 42px;
|
|
74
|
-
margin-bottom: 47px;
|
|
75
|
-
font-size: 16px;
|
|
76
|
-
font-weight: 400;
|
|
77
|
-
line-height: 16px;
|
|
78
|
-
color: ${({ theme }) => theme.textColor4};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@media (max-width: 768px) {
|
|
82
|
-
.walletList {
|
|
83
|
-
padding: 10px 28px 0;
|
|
84
|
-
min-height: 237px;
|
|
85
|
-
max-height: 237px;
|
|
86
|
-
overflow: auto;
|
|
87
|
-
|
|
88
|
-
.button {
|
|
89
|
-
font-size: 12px;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.question {
|
|
94
|
-
margin: 10px 25px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.answer {
|
|
98
|
-
margin: 0 25px 75px;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
`;
|
|
102
|
-
export default WalletListContainer;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import Text from '../Text';
|
|
3
|
-
import { FlexBox } from '../../styled';
|
|
4
|
-
import Icon from '../Icon';
|
|
5
|
-
import useSlotsWalletStore from '../../stores/SlotsWalletStore';
|
|
6
|
-
import type { ISlotsConnector } from '../../types/slotsType';
|
|
7
|
-
import WalletItem from './style';
|
|
8
|
-
import { useWalletKit } from '../../hooks/useWalletKit';
|
|
9
|
-
|
|
10
|
-
export interface IWalletTriggerButton {
|
|
11
|
-
connector: any;
|
|
12
|
-
}
|
|
13
|
-
export interface IWalletSlotTriggerButton {
|
|
14
|
-
slotsConnector: ISlotsConnector;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const WalletTriggerButton: React.FC<IWalletTriggerButton> = ({ connector }) => {
|
|
18
|
-
const { connectStatus } = useWalletKit();
|
|
19
|
-
|
|
20
|
-
const disabled = useMemo(() => {
|
|
21
|
-
return connectStatus === 'connected';
|
|
22
|
-
}, [connectStatus]);
|
|
23
|
-
|
|
24
|
-
const handleConnect = async () => {
|
|
25
|
-
if (disabled) return;
|
|
26
|
-
console.log('connector', connector);
|
|
27
|
-
await connector.connect();
|
|
28
|
-
};
|
|
29
|
-
return (
|
|
30
|
-
<WalletItem onClick={handleConnect} className={disabled ? 'disabled' : ''}>
|
|
31
|
-
<FlexBox className={'gap-10'}>
|
|
32
|
-
<Icon src={connector.icon || ''} />
|
|
33
|
-
<Text text={connector.name} />
|
|
34
|
-
</FlexBox>
|
|
35
|
-
</WalletItem>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const WalletSlotTriggerButton: React.FC<IWalletSlotTriggerButton> = ({ slotsConnector }) => {
|
|
40
|
-
const useAddConnector = useSlotsWalletStore((state: any) => state.addConnector);
|
|
41
|
-
useAddConnector(slotsConnector);
|
|
42
|
-
return (
|
|
43
|
-
<WalletItem>
|
|
44
|
-
<FlexBox className={'gap-10'}>
|
|
45
|
-
<Icon src={slotsConnector.walletIcon} />
|
|
46
|
-
<Text text={slotsConnector.walletName} />
|
|
47
|
-
</FlexBox>
|
|
48
|
-
</WalletItem>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { styled } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
const WalletItem = styled.div`
|
|
4
|
-
display: flex;
|
|
5
|
-
padding: 4px 12px;
|
|
6
|
-
border-radius: 12px;
|
|
7
|
-
cursor: pointer;
|
|
8
|
-
flex-shrink: 0;
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
user-select: none;
|
|
11
|
-
|
|
12
|
-
img {
|
|
13
|
-
width: 28px;
|
|
14
|
-
height: 28px;
|
|
15
|
-
border-radius: 6px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&:hover {
|
|
19
|
-
background: ${({ theme }) => theme.itemHoverBg};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&.disabled {
|
|
23
|
-
pointer-events: none;
|
|
24
|
-
background: none;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@media (max-width: 768px) {
|
|
28
|
-
width: 86px;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
|
|
31
|
-
> div {
|
|
32
|
-
box-sizing: border-box;
|
|
33
|
-
flex-direction: column;
|
|
34
|
-
align-items: center;
|
|
35
|
-
|
|
36
|
-
img {
|
|
37
|
-
width: 36px;
|
|
38
|
-
height: 36px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
> div {
|
|
42
|
-
line-height: 14px;
|
|
43
|
-
text-align: center;
|
|
44
|
-
|
|
45
|
-
span {
|
|
46
|
-
font-size: 12px;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
export default WalletItem;
|
package/src/default.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare module '*.svg' {
|
|
2
|
-
const dataUrl: string;
|
|
3
|
-
export default dataUrl;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module '*.png' {
|
|
7
|
-
const dataUrl: string;
|
|
8
|
-
export default dataUrl;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module 'content-hash' {
|
|
12
|
-
declare function decode(x: string): string;
|
|
13
|
-
declare function getCodec(x: string): string;
|
|
14
|
-
}
|
|
15
|
-
declare module '*.json' {
|
|
16
|
-
const value: any;
|
|
17
|
-
export default value;
|
|
18
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { walletHelperStore, type WalletHelperState } from '@web3jskit/wallethelper';
|
|
2
|
-
import { walletKitStore, AppModal, type WalletKitState } from '../stores';
|
|
3
|
-
|
|
4
|
-
type WalletKit = WalletHelperState & WalletKitState;
|
|
5
|
-
type WalletKitKeys = keyof WalletKit;
|
|
6
|
-
|
|
7
|
-
// use for react component
|
|
8
|
-
export const useWalletKit = () => {
|
|
9
|
-
const walletHelperStates = walletHelperStore((states: any) => states);
|
|
10
|
-
|
|
11
|
-
const walletKitStates = walletKitStore((states: any) => states);
|
|
12
|
-
|
|
13
|
-
// const provider = currentConnector?.provider || null;
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
...walletHelperStates,
|
|
17
|
-
// provider,
|
|
18
|
-
|
|
19
|
-
...walletKitStates
|
|
20
|
-
} as WalletKit;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// use for pure js
|
|
24
|
-
export const getWalletKit = () => {
|
|
25
|
-
const walletHelperStates = walletHelperStore.getState();
|
|
26
|
-
const walletKitStates = walletKitStore.getState();
|
|
27
|
-
|
|
28
|
-
const exportStates = {
|
|
29
|
-
...walletHelperStates,
|
|
30
|
-
...walletKitStates
|
|
31
|
-
} as WalletKit;
|
|
32
|
-
// only export get/set methods
|
|
33
|
-
Object.keys(exportStates).forEach((key: string) => {
|
|
34
|
-
if (typeof exportStates[key as WalletKitKeys] !== 'function') {
|
|
35
|
-
delete exportStates[key as WalletKitKeys];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return exportStates as WalletKit;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export { AppModal };
|
package/src/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { SupportWallet } from '@web3jskit/wallethelper';
|
|
2
|
-
export * from './components/WalletKitProvider';
|
|
3
|
-
export * from './components/ConnectButton';
|
|
4
|
-
export * from './types/configType';
|
|
5
|
-
export * from './types/slotsType';
|
|
6
|
-
export { createSlots } from './wallets/SlotsWallets/index';
|
|
7
|
-
export { WalletSlotTriggerButton } from './components/WalletTriggerButton/index';
|
|
8
|
-
export { useWalletKit, getWalletKit } from './hooks/useWalletKit';
|
|
9
|
-
export { AppModal } from './stores';
|
package/src/locals/i18n.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import i18n from 'i18next';
|
|
2
|
-
import { initReactI18next } from 'react-i18next';
|
|
3
|
-
import { resources } from './resources';
|
|
4
|
-
|
|
5
|
-
// i18n.use(LanguageDetector)
|
|
6
|
-
i18n.use(initReactI18next).init({
|
|
7
|
-
resources,
|
|
8
|
-
react: {
|
|
9
|
-
useSuspense: true
|
|
10
|
-
},
|
|
11
|
-
fallbackLng: 'en',
|
|
12
|
-
preload: ['zh-CN', 'en', 'zh', 'en-US'],
|
|
13
|
-
keySeparator: false,
|
|
14
|
-
interpolation: {
|
|
15
|
-
escapeValue: false
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export default i18n;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "wallet",
|
|
3
|
-
"connectWallet": "Connect Wallet",
|
|
4
|
-
"introduceQuestion": "What is a wallet?",
|
|
5
|
-
"introduceAnswer": "Your Digital Asset Home",
|
|
6
|
-
"introduceDetail": "Wallets are used to send, receive, store, and display digital assets such as Ethereum and NFTs.",
|
|
7
|
-
"getWallet": "Get Wallet",
|
|
8
|
-
"learnMore": "Learn More",
|
|
9
|
-
"getWalletTitle": "Get a wallet",
|
|
10
|
-
"getWalletTips": "Mobile Wallet and Expansion,",
|
|
11
|
-
"getWalletQuestion": "Isn't that what you're looking for?",
|
|
12
|
-
"getWalletAnswer": "Select a wallet on the left to start using different wallet providers.",
|
|
13
|
-
"forChrome": "for Chrome",
|
|
14
|
-
"chromeDescription": "Access your wallet directly from your favorite web browser.",
|
|
15
|
-
"addToChrome": "Add to Chrome",
|
|
16
|
-
"forMobile": "for Mobile",
|
|
17
|
-
"mobileDescription": "Explore the world of Ethereum with a mobile wallet.",
|
|
18
|
-
"getMobileApp": "Get the App",
|
|
19
|
-
"getAppTip": "Scan with your phone to download for iOS or Android",
|
|
20
|
-
"get": "Get",
|
|
21
|
-
"continue": "Continue",
|
|
22
|
-
"opening": "Opening",
|
|
23
|
-
"confirmConnection": "Confirm connection in extension",
|
|
24
|
-
"copyAddress": "Copy Address",
|
|
25
|
-
"copied": "Copied!",
|
|
26
|
-
"disConnect": "Disconnect",
|
|
27
|
-
"installed": "Installed",
|
|
28
|
-
"run": "Run",
|
|
29
|
-
"more": "More"
|
|
30
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "钱包",
|
|
3
|
-
"connectWallet": "连接钱包",
|
|
4
|
-
"introduceQuestion": "什么是钱包?",
|
|
5
|
-
"introduceAnswer": "您的数字资产之家",
|
|
6
|
-
"introduceDetail": "钱包用于发送、接收、存储和展示数字资产,例如以太坊和 NFT。",
|
|
7
|
-
"getWallet": "获取钱包",
|
|
8
|
-
"learnMore": "了解更多",
|
|
9
|
-
"getWalletTitle": "获取钱包",
|
|
10
|
-
"getWalletTips": "移动钱包和扩展程序",
|
|
11
|
-
"getWalletQuestion": "不是你要找的吗?",
|
|
12
|
-
"getWalletAnswer": "在左侧选择一个钱包以开始使用不同的钱包提供商。",
|
|
13
|
-
"forChrome": "为 Chrome",
|
|
14
|
-
"chromeDescription": "从您最喜欢的网络浏览器直接访问您的钱包。",
|
|
15
|
-
"addToChrome": "添加到 Chrome",
|
|
16
|
-
"forMobile": "用于移动",
|
|
17
|
-
"mobileDescription": "使用移动钱包探索以太坊的世界。",
|
|
18
|
-
"getMobileApp": "获取应用",
|
|
19
|
-
"getAppTip": "用手机扫描下载 iOS 或 Android",
|
|
20
|
-
"get": "获取",
|
|
21
|
-
"continue": "继续",
|
|
22
|
-
"opening": "打开",
|
|
23
|
-
"confirmConnection": "在扩展程序中确认连接",
|
|
24
|
-
"copyAddress": "复制地址",
|
|
25
|
-
"copied": "已复制!",
|
|
26
|
-
"disConnect": "断开连接",
|
|
27
|
-
"installed": "已安装",
|
|
28
|
-
"run": "流行",
|
|
29
|
-
"more": "更多"
|
|
30
|
-
}
|
package/src/locals/resources.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { create } from 'zustand';
|
|
2
|
-
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
3
|
-
import type { ISlotsConnector } from '../types/slotsType';
|
|
4
|
-
|
|
5
|
-
export interface ISlotsWallets {
|
|
6
|
-
walletConnectors: {
|
|
7
|
-
[key: string]: ISlotsConnector;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const useSlotsWalletStore = create(
|
|
12
|
-
persist(
|
|
13
|
-
(set, get: () => ISlotsWallets) => ({
|
|
14
|
-
walletConnectors: {},
|
|
15
|
-
addConnector({ walletName, walletIcon, connector, uuid, connectorNamespace }: ISlotsConnector) {
|
|
16
|
-
return set(state => {
|
|
17
|
-
return {
|
|
18
|
-
walletConnectors: {
|
|
19
|
-
...state.walletConnectors,
|
|
20
|
-
[uuid]: { walletName, walletIcon, connector, uuid, connectorNamespace }
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
removeConnector(uuid: string) {
|
|
27
|
-
return set(state => {
|
|
28
|
-
if (get().walletConnectors[uuid]) {
|
|
29
|
-
return {
|
|
30
|
-
walletConnectors: Object.fromEntries(Object.entries(state.walletConnectors).filter(([k]) => k !== uuid))
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return { walletConnectors: { ...state.walletConnectors } };
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
clearConnectors() {
|
|
38
|
-
return set(() => ({ walletConnectors: {} }));
|
|
39
|
-
}
|
|
40
|
-
}),
|
|
41
|
-
{
|
|
42
|
-
name: 'WALLET_KIT_SLOTS',
|
|
43
|
-
storage: createJSONStorage(() => localStorage)
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
export default useSlotsWalletStore;
|