@matchain/matchid-sdk-react 0.1.56 → 0.1.57-alpha.1
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/api.d.mts +2 -2
- package/dist/api.d.ts +2 -2
- package/dist/api.js +96 -48
- package/dist/api.js.map +1 -1
- package/dist/api.mjs +3 -3
- package/dist/chains.d.mts +1 -1
- package/dist/chains.d.ts +1 -1
- package/dist/{chunk-KFB23MLQ.mjs → chunk-6RNCNC65.mjs} +353 -217
- package/dist/chunk-6RNCNC65.mjs.map +1 -0
- package/dist/{chunk-GD7URBBZ.mjs → chunk-7SUDHG7S.mjs} +41 -1
- package/dist/chunk-7SUDHG7S.mjs.map +1 -0
- package/dist/{chunk-NYE6DBEZ.mjs → chunk-EAZNOQRK.mjs} +2 -2
- package/dist/components.d.mts +3 -3
- package/dist/components.d.ts +3 -3
- package/dist/components.js +498 -368
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +2 -2
- package/dist/hooks.d.mts +2 -3
- package/dist/hooks.d.ts +2 -3
- package/dist/hooks.js +228 -182
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +2 -2
- package/dist/icon.d.mts +2 -2
- package/dist/icon.d.ts +2 -2
- package/dist/icon.js +40 -0
- package/dist/icon.js.map +1 -1
- package/dist/icon.mjs +5 -1
- package/dist/{index-CBcBTQyU.d.mts → index-84CqVi2I.d.mts} +1 -1
- package/dist/index-B70k4Jpk.d.ts +7138 -0
- package/dist/index-BJJ0Gb6v.d.mts +7138 -0
- package/dist/{index-DlaCsN95.d.ts → index-BNqdFiOo.d.ts} +1 -1
- package/dist/{index-xThRnNN3.d.mts → index-BctnHnJp.d.ts} +11 -3
- package/dist/{index-CjekOYJl.d.mts → index-BqI0PEIi.d.mts} +1 -1
- package/dist/{index-BcuSCgol.d.ts → index-C2hr7zlN.d.ts} +5 -3
- package/dist/{index-CD0dACxf.d.mts → index-CTHpnEoB.d.mts} +5 -3
- package/dist/{index-CER00guz.d.mts → index-Car1jFyN.d.mts} +1 -1
- package/dist/{index-B50DU_xT.d.mts → index-CboftuIp.d.mts} +2 -0
- package/dist/{index-B50DU_xT.d.ts → index-CboftuIp.d.ts} +2 -0
- package/dist/{index-o0WW1c5O.d.ts → index-CcVHENNv.d.ts} +1 -1
- package/dist/{index-DkIIQLbh.d.ts → index-Cqdz_5bE.d.ts} +2 -2
- package/dist/{index-DdN22cwf.d.ts → index-CvzpMw3N.d.ts} +1 -1
- package/dist/{index-DN-jrh8-.d.ts → index-DkijpM5Q.d.mts} +11 -3
- package/dist/{index-lh6qBAf_.d.mts → index-DxHhOW24.d.mts} +2 -2
- package/dist/index.css +209 -46
- package/dist/index.d.mts +166 -88
- package/dist/index.d.ts +166 -88
- package/dist/index.js +599 -427
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{types-CheN9vHJ.d.mts → types-BrVeC0c8.d.mts} +1 -1
- package/dist/{types-CheN9vHJ.d.ts → types-BrVeC0c8.d.ts} +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/ui.d.mts +3 -3
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +127 -110
- package/dist/ui.js.map +1 -1
- package/dist/ui.mjs +2 -2
- package/example/src/App.tsx +65 -60
- package/example/src/config/index.ts +8 -6
- package/example/src/pages/Wallet/index.tsx +88 -88
- package/package.json +2 -2
- package/dist/chunk-GD7URBBZ.mjs.map +0 -1
- package/dist/chunk-KFB23MLQ.mjs.map +0 -1
- package/dist/index-BlMLqmS2.d.mts +0 -3341
- package/dist/index-C1Nyy5zx.d.ts +0 -3341
- /package/dist/{chunk-NYE6DBEZ.mjs.map → chunk-EAZNOQRK.mjs.map} +0 -0
package/dist/ui.mjs
CHANGED
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
Skeleton_default,
|
|
18
18
|
Switch,
|
|
19
19
|
Tabs
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-6RNCNC65.mjs";
|
|
21
21
|
import "./chunk-JX73EY6V.mjs";
|
|
22
22
|
import "./chunk-UA6XHZHX.mjs";
|
|
23
23
|
import "./chunk-IZOOVZAD.mjs";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-7SUDHG7S.mjs";
|
|
25
25
|
import "./chunk-XM6CYEXN.mjs";
|
|
26
26
|
import "./chunk-J5LGTIGS.mjs";
|
|
27
27
|
export {
|
package/example/src/App.tsx
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import React, {useEffect, useMemo, useState} from "react";
|
|
2
|
-
import {MatchProvider, wagmiConfig} from "@matchain/matchid-sdk-react";
|
|
3
|
-
import {BrowserRouter as Router, Routes, Route, Link, useLocation} from 'react-router-dom';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { MatchProvider, wagmiConfig } from "@matchain/matchid-sdk-react";
|
|
3
|
+
import { BrowserRouter as Router, Routes, Route, Link, useLocation } from 'react-router-dom';
|
|
4
4
|
import Home from "./pages/Home";
|
|
5
5
|
import './app.css'
|
|
6
6
|
import User from "./pages/User";
|
|
7
7
|
import "@matchain/matchid-sdk-react/index.css"
|
|
8
8
|
import Wallet from "@/pages/Wallet";
|
|
9
|
-
import {LocaleList} from "@/config";
|
|
10
|
-
import {LocaleType} from "@matchain/matchid-sdk-react/types";
|
|
11
|
-
import {useUserInfo} from "@matchain/matchid-sdk-react/hooks";
|
|
9
|
+
import { LocaleList } from "@/config";
|
|
10
|
+
import { LocaleType } from "@matchain/matchid-sdk-react/types";
|
|
11
|
+
import { useMatchEvents, useUserInfo } from "@matchain/matchid-sdk-react/hooks";
|
|
12
12
|
import RoutePrivate from "@/components/RoutePrivate";
|
|
13
13
|
import useLocalStore from "@/store/useLocalStore";
|
|
14
|
-
import {LoginButton} from "@matchain/matchid-sdk-react/components";
|
|
14
|
+
import { LoginButton } from "@matchain/matchid-sdk-react/components";
|
|
15
15
|
import UI from "@/pages/UI";
|
|
16
16
|
import TgApp from "@/pages/TgApp";
|
|
17
|
-
import {WagmiProvider} from "wagmi";
|
|
17
|
+
import { WagmiProvider } from "wagmi";
|
|
18
18
|
import useStore from "@/store/useStore";
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
function Nav() {
|
|
22
|
-
const {isLogin} = useUserInfo()
|
|
22
|
+
const { isLogin } = useUserInfo()
|
|
23
23
|
const location = useLocation()
|
|
24
24
|
const menus = useMemo(() => {
|
|
25
25
|
const list: {
|
|
@@ -28,43 +28,43 @@ function Nav() {
|
|
|
28
28
|
onActive: boolean
|
|
29
29
|
hidden?: boolean
|
|
30
30
|
}[] = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
31
|
+
{
|
|
32
|
+
name: 'Home',
|
|
33
|
+
url: '/',
|
|
34
|
+
onActive: location.pathname === '/'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'UI',
|
|
38
|
+
url: '/ui',
|
|
39
|
+
onActive: location.pathname === '/ui'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'TgApp',
|
|
43
|
+
url: '/tgapp',
|
|
44
|
+
onActive: location.pathname === '/tgapp'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'User',
|
|
48
|
+
url: '/user',
|
|
49
|
+
onActive: location.pathname === '/user'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Wallet',
|
|
53
|
+
url: '/wallet',
|
|
54
|
+
onActive: location.pathname === '/wallet',
|
|
55
|
+
hidden: !isLogin
|
|
56
|
+
},
|
|
57
|
+
]
|
|
58
58
|
return list
|
|
59
59
|
}, [location.pathname, isLogin])
|
|
60
60
|
return <>
|
|
61
61
|
<nav className={`text-2xl mb-5 p-2 text-red-600 flex gap-10 flex-wrap`}>
|
|
62
62
|
{menus.map((menu) => {
|
|
63
63
|
return <Link key={menu.url} to={menu.url}
|
|
64
|
-
|
|
64
|
+
className={`text-2xl ${menu.onActive ? 'text-red-600' : 'text-gray-400'} ${menu.hidden ? 'hidden' : ''}`}>{menu.name}</Link>
|
|
65
65
|
})}
|
|
66
66
|
|
|
67
|
-
<LoginButton/>
|
|
67
|
+
<LoginButton recommendMethods={['wallet', "email"]} walletMethods={['evm']} methods={['google', 'kakao']} />
|
|
68
68
|
</nav>
|
|
69
69
|
|
|
70
70
|
</>
|
|
@@ -85,44 +85,44 @@ function RouterApp() {
|
|
|
85
85
|
color,
|
|
86
86
|
setColor
|
|
87
87
|
} = useLocalStore()
|
|
88
|
-
const {appSecret,setAppSecret} = useStore()
|
|
88
|
+
const { appSecret, setAppSecret } = useStore()
|
|
89
89
|
|
|
90
90
|
return <Router>
|
|
91
91
|
<div className={`mb-2 p-2 flex gap-2 flex-col`}>
|
|
92
92
|
<div>
|
|
93
93
|
<label>BackgroundColor:</label>
|
|
94
94
|
<input value={backgroundColor} placeholder={"BackgroundColor"} className={"border-solid border"}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
onChange={(ele) => {
|
|
96
|
+
setBackgroundColor(ele.target.value)
|
|
97
|
+
}} /></div>
|
|
98
98
|
<div>
|
|
99
99
|
<label>Color:</label>
|
|
100
100
|
<input value={color} placeholder={"Color"} className={"border-solid border"} onChange={(ele) => {
|
|
101
101
|
setColor(ele.target.value)
|
|
102
|
-
}}/></div>
|
|
102
|
+
}} /></div>
|
|
103
103
|
<div>
|
|
104
104
|
<label>Appid:</label>
|
|
105
105
|
<input value={appid} placeholder={"Appid"} className={"border-solid border"} onChange={(ele) => {
|
|
106
106
|
setAppid(ele.target.value)
|
|
107
|
-
}}/></div>
|
|
107
|
+
}} /></div>
|
|
108
108
|
<div>
|
|
109
109
|
<label>AppSecret:</label>
|
|
110
110
|
<input value={appSecret} placeholder={"AppSecret"} className={"border-solid border"} onChange={(ele) => {
|
|
111
111
|
setAppSecret(ele.target.value)
|
|
112
|
-
}}/></div>
|
|
112
|
+
}} /></div>
|
|
113
113
|
<div>
|
|
114
114
|
<label>AuthEndpoint:</label>
|
|
115
115
|
<input value={endpoints?.auth || ''} placeholder={"Auth Endpoint"} className={"border-solid border"}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
onChange={(ele) => {
|
|
117
|
+
setEndpoints({ ...endpoints, auth: ele.target.value })
|
|
118
|
+
}} />
|
|
119
119
|
</div>
|
|
120
120
|
<div>
|
|
121
121
|
<label>BackEndpoint:</label>
|
|
122
122
|
<input value={endpoints?.back || ''} placeholder={"Back Endpoint"} className={"border-solid border"}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
onChange={(ele) => {
|
|
124
|
+
setEndpoints({ ...endpoints, back: ele.target.value })
|
|
125
|
+
}} />
|
|
126
126
|
</div>
|
|
127
127
|
<div>
|
|
128
128
|
<label>Locale:</label>
|
|
@@ -141,15 +141,15 @@ function RouterApp() {
|
|
|
141
141
|
</select>
|
|
142
142
|
</div>
|
|
143
143
|
</div>
|
|
144
|
-
<Nav/>
|
|
144
|
+
<Nav />
|
|
145
145
|
<div className={`p-4`}>
|
|
146
146
|
<Routes>
|
|
147
|
-
<Route path="/" element={<Home/>}/>
|
|
148
|
-
<Route path="/ui" element={<UI/>}/>
|
|
149
|
-
<Route path="/tgapp" element={<TgApp/>}/>
|
|
150
|
-
<Route element={<RoutePrivate/>}>
|
|
151
|
-
<Route path="/user" element={<User/>}/>
|
|
152
|
-
<Route path="/wallet" element={<Wallet/>}/>
|
|
147
|
+
<Route path="/" element={<Home />} />
|
|
148
|
+
<Route path="/ui" element={<UI />} />
|
|
149
|
+
<Route path="/tgapp" element={<TgApp />} />
|
|
150
|
+
<Route element={<RoutePrivate />}>
|
|
151
|
+
<Route path="/user" element={<User />} />
|
|
152
|
+
<Route path="/wallet" element={<Wallet />} />
|
|
153
153
|
</Route>
|
|
154
154
|
</Routes>
|
|
155
155
|
</div>
|
|
@@ -157,8 +157,13 @@ function RouterApp() {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
function App() {
|
|
160
|
-
const {appid, locale, endpoints, walletType, backgroundColor, color} = useLocalStore()
|
|
160
|
+
const { appid, locale, endpoints, walletType, backgroundColor, color } = useLocalStore()
|
|
161
161
|
|
|
162
|
+
useMatchEvents({
|
|
163
|
+
onBind() {
|
|
164
|
+
console.log("bind event");
|
|
165
|
+
},
|
|
166
|
+
});
|
|
162
167
|
return <div style={{
|
|
163
168
|
backgroundColor: backgroundColor,
|
|
164
169
|
color: color
|
|
@@ -180,7 +185,7 @@ function App() {
|
|
|
180
185
|
type: walletType
|
|
181
186
|
}}
|
|
182
187
|
>
|
|
183
|
-
<RouterApp/>
|
|
188
|
+
<RouterApp />
|
|
184
189
|
</MatchProvider>
|
|
185
190
|
</WagmiProvider>
|
|
186
191
|
</div>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {LoginMethodType, WalletType,RecommendLoginMethodType,OtherLoginMethodType} from "@matchain/matchid-sdk-react/types";
|
|
1
|
+
import { LoginMethodType, WalletType, RecommendLoginMethodType, OtherLoginMethodType } from "@matchain/matchid-sdk-react/types";
|
|
2
2
|
|
|
3
3
|
export const LoginMethod = [
|
|
4
4
|
"wallet",
|
|
@@ -14,7 +14,9 @@ export const LoginMethod = [
|
|
|
14
14
|
'discord',
|
|
15
15
|
'linkedin',
|
|
16
16
|
'facebook',
|
|
17
|
-
"youtube"
|
|
17
|
+
"youtube",
|
|
18
|
+
"kakao",
|
|
19
|
+
"email"
|
|
18
20
|
]
|
|
19
21
|
export const LocaleList = [
|
|
20
22
|
"en", "zh", "tw", "fr", "ja", "ko", "vi", "es", "pt"
|
|
@@ -23,12 +25,12 @@ export const LocaleList = [
|
|
|
23
25
|
export const CEXList = [
|
|
24
26
|
"Gate", "Coinbase", "Kucoin", 'Bitget', 'OKX', 'Bybit', 'Binance']
|
|
25
27
|
|
|
26
|
-
export const WalletList:WalletType[] = [
|
|
27
|
-
'btc', 'sol', 'evm', 'tron',"ton"
|
|
28
|
+
export const WalletList: WalletType[] = [
|
|
29
|
+
'btc', 'sol', 'evm', 'tron', "ton"
|
|
28
30
|
]
|
|
29
|
-
export const LoginMethodList
|
|
31
|
+
export const LoginMethodList: OtherLoginMethodType[] = ['twitter', 'discord', 'github', 'telegram', 'linkedin', 'facebook', 'youtube']
|
|
30
32
|
|
|
31
|
-
export const RecommendLoginMethodList:RecommendLoginMethodType[] = ["wallet","email","google"]
|
|
33
|
+
export const RecommendLoginMethodList: RecommendLoginMethodType[] = ["wallet", "email", "google"]
|
|
32
34
|
|
|
33
35
|
export const LOGIN_METHOD_MAP = {
|
|
34
36
|
email: 'Email',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {useUserInfo, useWallet} from "@matchain/matchid-sdk-react/hooks"
|
|
2
|
-
import {Input, Button} from "@matchain/matchid-sdk-react/components"
|
|
3
|
-
import React, {useEffect, useMemo, useState} from "react";
|
|
1
|
+
import { useUserInfo, useWallet } from "@matchain/matchid-sdk-react/hooks"
|
|
2
|
+
import { Input, Button } from "@matchain/matchid-sdk-react/components"
|
|
3
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
4
4
|
import {
|
|
5
5
|
createPublicClient,
|
|
6
6
|
formatUnits,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
Transport,
|
|
11
11
|
HttpTransportConfig, http, TransactionSerializable
|
|
12
12
|
} from "viem";
|
|
13
|
-
import {useQuery} from "@tanstack/react-query";
|
|
13
|
+
import { useQuery } from "@tanstack/react-query";
|
|
14
14
|
import {
|
|
15
15
|
mainnet,
|
|
16
16
|
arbitrum,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
polygonAmoy,
|
|
34
34
|
zkSync,
|
|
35
35
|
} from 'viem/chains';
|
|
36
|
-
import {MatchMain, MatchTest} from "@matchain/matchid-sdk-react/chains";
|
|
36
|
+
import { MatchMain, MatchTest } from "@matchain/matchid-sdk-react/chains";
|
|
37
37
|
import useLocalStore from "@/store/useLocalStore";
|
|
38
38
|
import ButtonGroup from "@/components/ButtonGroup";
|
|
39
39
|
import Erc20Abi from "@/abi/erc20.json";
|
|
@@ -42,14 +42,14 @@ import AssetListModal from "@/pages/Wallet/components/AssetListModal";
|
|
|
42
42
|
import ImportTokenListModal from "@/pages/Wallet/components/ImportTokenListModal";
|
|
43
43
|
import WalletChainListModal from "@/pages/Wallet/components/WalletChainListModal";
|
|
44
44
|
import MatchWallet from "@/pages/Wallet/components/MatchWallet";
|
|
45
|
-
import {ethers} from "ethers";
|
|
45
|
+
import { ethers } from "ethers";
|
|
46
46
|
|
|
47
47
|
const chainList = [
|
|
48
48
|
mainnet,
|
|
49
49
|
bsc,
|
|
50
50
|
bscTestnet,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
MatchMain,
|
|
52
|
+
MatchTest,
|
|
53
53
|
arbitrum,
|
|
54
54
|
arbitrumGoerli,
|
|
55
55
|
arbitrumNova,
|
|
@@ -70,16 +70,16 @@ const chainList = [
|
|
|
70
70
|
]
|
|
71
71
|
|
|
72
72
|
export default function Wallet() {
|
|
73
|
-
const [modal, setModal] = useState<'chainList' | 'assetList' | 'importTokenList' | 'walletChainList' | ''
|
|
73
|
+
const [modal, setModal] = useState<'chainList' | 'assetList' | 'importTokenList' | 'walletChainList' | ''>('')
|
|
74
74
|
|
|
75
|
-
const {initChainId, setInitChainId} = useLocalStore()
|
|
76
|
-
const {overview} = useUserInfo()
|
|
75
|
+
const { initChainId, setInitChainId } = useLocalStore()
|
|
76
|
+
const { overview } = useUserInfo()
|
|
77
77
|
|
|
78
78
|
const [message, setMessage] = useState('hello')
|
|
79
79
|
const [toAddress, setToAddress] = useState('')
|
|
80
80
|
const [toAmount, setToAmount] = useState('0.000001')
|
|
81
81
|
const [data, setToData] = useState('0x')
|
|
82
|
-
const {address, evmAccount, createWalletClient, walletReady} = useWallet()
|
|
82
|
+
const { address, evmAccount, createWalletClient, walletReady } = useWallet()
|
|
83
83
|
const chain = chainList.find((chain) => chain.id === initChainId)
|
|
84
84
|
|
|
85
85
|
const walletClient = createWalletClient({
|
|
@@ -108,7 +108,7 @@ export default function Wallet() {
|
|
|
108
108
|
queryKey: ['balance', address],
|
|
109
109
|
refetchInterval: 15_000,
|
|
110
110
|
queryFn: async () => {
|
|
111
|
-
return await publicClient.getBalance({address: address as `0x${string}`})
|
|
111
|
+
return await publicClient.getBalance({ address: address as `0x${string}` })
|
|
112
112
|
}
|
|
113
113
|
})
|
|
114
114
|
//to eth
|
|
@@ -125,7 +125,7 @@ export default function Wallet() {
|
|
|
125
125
|
useEffect(() => {
|
|
126
126
|
gasPriceQuery.refetch()
|
|
127
127
|
balanceQuery.refetch()
|
|
128
|
-
}, [chain,address]);
|
|
128
|
+
}, [chain, address]);
|
|
129
129
|
|
|
130
130
|
const onSign = async () => {
|
|
131
131
|
if (!walletClient) return;
|
|
@@ -149,7 +149,7 @@ export default function Wallet() {
|
|
|
149
149
|
const request = await walletClient.prepareTransactionRequest(transaction)
|
|
150
150
|
const res = await evmAccount.signTransaction!(request as TransactionSerializable)
|
|
151
151
|
const tx = ethers.utils.parseTransaction(res);
|
|
152
|
-
console.log('tx',tx)
|
|
152
|
+
console.log('tx', tx)
|
|
153
153
|
setTransactionSign(res)
|
|
154
154
|
} catch (e) {
|
|
155
155
|
console.error(e)
|
|
@@ -178,16 +178,16 @@ export default function Wallet() {
|
|
|
178
178
|
|
|
179
179
|
<ButtonGroup title={"QueryList"}>
|
|
180
180
|
<button className={`bg-gray-300 p-1 rounded`}
|
|
181
|
-
|
|
181
|
+
onClick={() => setModal('chainList')}>ChainList
|
|
182
182
|
</button>
|
|
183
183
|
<button className={`bg-gray-300 p-1 rounded`}
|
|
184
|
-
|
|
184
|
+
onClick={() => setModal('assetList')}>AssetList
|
|
185
185
|
</button>
|
|
186
186
|
<button className={`bg-gray-300 p-1 rounded`}
|
|
187
|
-
|
|
187
|
+
onClick={() => setModal('importTokenList')}>ImportTokenList
|
|
188
188
|
</button>
|
|
189
189
|
<button className={`bg-gray-300 p-1 rounded`}
|
|
190
|
-
|
|
190
|
+
onClick={() => setModal('walletChainList')}>WalletChainList
|
|
191
191
|
</button>
|
|
192
192
|
{/*<button className={`bg-gray-300 p-1 rounded`}*/}
|
|
193
193
|
{/* onClick={exportWallet}>Export*/}
|
|
@@ -208,7 +208,7 @@ export default function Wallet() {
|
|
|
208
208
|
</ButtonGroup>
|
|
209
209
|
<ButtonGroup title={"Signature Message"}>
|
|
210
210
|
<input className="border px-[8px]" type={'text'} placeholder={'message'} value={message}
|
|
211
|
-
|
|
211
|
+
onChange={(e) => setMessage(e.target.value)} />
|
|
212
212
|
<Button onClick={onSign} size={"sm"} disabled={!walletReady}>Sign message</Button>
|
|
213
213
|
</ButtonGroup>
|
|
214
214
|
<ButtonGroup title={"Signature Result"}>
|
|
@@ -224,17 +224,17 @@ export default function Wallet() {
|
|
|
224
224
|
<div>
|
|
225
225
|
To Address:
|
|
226
226
|
<input className="border" type={'text'} placeholder={'to address'} value={toAddress}
|
|
227
|
-
|
|
227
|
+
onChange={(e) => setToAddress(e.target.value)} />
|
|
228
228
|
</div>
|
|
229
229
|
<div>
|
|
230
230
|
Amount:
|
|
231
231
|
<input className="border" type={'text'} placeholder={'amount'} value={toAmount}
|
|
232
|
-
|
|
232
|
+
onChange={(e) => setToAmount(e.target.value)} />
|
|
233
233
|
</div>
|
|
234
234
|
<div>
|
|
235
235
|
Data:
|
|
236
236
|
<input className="border" type={'text'} placeholder={'data'} value={data}
|
|
237
|
-
|
|
237
|
+
onChange={(e) => setToData(e.target.value)} />
|
|
238
238
|
</div>
|
|
239
239
|
<ButtonGroup>
|
|
240
240
|
<Button onClick={onSignTransaction} size={"sm"} disabled={!walletReady}>Sign</Button>
|
|
@@ -247,20 +247,20 @@ export default function Wallet() {
|
|
|
247
247
|
<div className={`flex-1 flex-wrap break-all`}>{hash || '-'}</div>
|
|
248
248
|
</ButtonGroup>
|
|
249
249
|
|
|
250
|
-
{modal == 'chainList' && <ChainListModal isOpen onClose={() => setModal('')}/>}
|
|
251
|
-
{modal == 'walletChainList' && <WalletChainListModal isOpen onClose={() => setModal('')}/>}
|
|
252
|
-
{modal == 'assetList' && <AssetListModal isOpen onClose={() => setModal('')}/>}
|
|
253
|
-
{modal == 'importTokenList' && <ImportTokenListModal isOpen onClose={() => setModal('')}/>}
|
|
250
|
+
{modal == 'chainList' && <ChainListModal isOpen onClose={() => setModal('')} />}
|
|
251
|
+
{modal == 'walletChainList' && <WalletChainListModal isOpen onClose={() => setModal('')} />}
|
|
252
|
+
{modal == 'assetList' && <AssetListModal isOpen onClose={() => setModal('')} />}
|
|
253
|
+
{modal == 'importTokenList' && <ImportTokenListModal isOpen onClose={() => setModal('')} />}
|
|
254
254
|
|
|
255
|
-
<ERC20/>
|
|
256
|
-
<MatchWallet/>
|
|
255
|
+
<ERC20 />
|
|
256
|
+
<MatchWallet />
|
|
257
257
|
</div>
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
function ERC20() {
|
|
261
|
-
const {initChainId, erc20Address, setErc20Address} = useLocalStore()
|
|
261
|
+
const { initChainId, erc20Address, setErc20Address } = useLocalStore()
|
|
262
262
|
|
|
263
|
-
const {address, evmAccount, createWalletClient, walletReady} = useWallet()
|
|
263
|
+
const { address, evmAccount, createWalletClient, walletReady } = useWallet()
|
|
264
264
|
|
|
265
265
|
const chain = chainList.find((chain) => chain.id === initChainId)
|
|
266
266
|
const publicClient = createPublicClient({
|
|
@@ -278,7 +278,7 @@ function ERC20() {
|
|
|
278
278
|
args: []
|
|
279
279
|
}) as number
|
|
280
280
|
},
|
|
281
|
-
enabled
|
|
281
|
+
enabled: !!erc20Address
|
|
282
282
|
})
|
|
283
283
|
|
|
284
284
|
const symbolQuery = useQuery({
|
|
@@ -291,7 +291,7 @@ function ERC20() {
|
|
|
291
291
|
args: []
|
|
292
292
|
}) as string
|
|
293
293
|
},
|
|
294
|
-
enabled
|
|
294
|
+
enabled: !!erc20Address
|
|
295
295
|
})
|
|
296
296
|
|
|
297
297
|
const balanceQuery = useQuery({
|
|
@@ -299,58 +299,58 @@ function ERC20() {
|
|
|
299
299
|
refetchInterval: 15_000,
|
|
300
300
|
queryFn: async () => {
|
|
301
301
|
return await publicClient.readContract({
|
|
302
|
-
abi:Erc20Abi,
|
|
303
|
-
address:erc20Address as `0x${string}`,
|
|
304
|
-
functionName:'balanceOf',
|
|
305
|
-
args:[address]
|
|
302
|
+
abi: Erc20Abi,
|
|
303
|
+
address: erc20Address as `0x${string}`,
|
|
304
|
+
functionName: 'balanceOf',
|
|
305
|
+
args: [address]
|
|
306
306
|
}) as bigint
|
|
307
307
|
},
|
|
308
|
-
enabled
|
|
308
|
+
enabled: !!erc20Address && !!address
|
|
309
309
|
})
|
|
310
310
|
|
|
311
|
-
const balanceUnit = useMemo(()=>{
|
|
312
|
-
if(!decimalsQuery.data) return ''
|
|
313
|
-
if(!balanceQuery.data) return ''
|
|
311
|
+
const balanceUnit = useMemo(() => {
|
|
312
|
+
if (!decimalsQuery.data) return ''
|
|
313
|
+
if (!balanceQuery.data) return ''
|
|
314
314
|
|
|
315
|
-
return formatUnits(balanceQuery.data,decimalsQuery.data)
|
|
316
|
-
},[balanceQuery.data,decimalsQuery.data])
|
|
315
|
+
return formatUnits(balanceQuery.data, decimalsQuery.data)
|
|
316
|
+
}, [balanceQuery.data, decimalsQuery.data])
|
|
317
317
|
|
|
318
318
|
// console.log(balanceQuery,symbolQuery,decimalsQuery)
|
|
319
319
|
|
|
320
|
-
function Transfer(){
|
|
320
|
+
function Transfer() {
|
|
321
321
|
const [to, setTo] = useState(address)
|
|
322
322
|
const [hash, setHash] = useState('')
|
|
323
323
|
const [amount, setAmount] = useState('0.0001')
|
|
324
|
-
const [loading,setLoading] = useState(false)
|
|
325
|
-
const onSend = async()=>{
|
|
326
|
-
try{
|
|
324
|
+
const [loading, setLoading] = useState(false)
|
|
325
|
+
const onSend = async () => {
|
|
326
|
+
try {
|
|
327
327
|
setLoading(true)
|
|
328
|
-
if(!walletReady) throw new Error('wallet not ready')
|
|
329
|
-
if(!evmAccount) throw new Error('account not ready')
|
|
330
|
-
if(!erc20Address) throw new Error('erc20Address not ready')
|
|
331
|
-
if(!to) throw new Error('to not ready')
|
|
332
|
-
if(!amount) throw new Error('amount not ready')
|
|
328
|
+
if (!walletReady) throw new Error('wallet not ready')
|
|
329
|
+
if (!evmAccount) throw new Error('account not ready')
|
|
330
|
+
if (!erc20Address) throw new Error('erc20Address not ready')
|
|
331
|
+
if (!to) throw new Error('to not ready')
|
|
332
|
+
if (!amount) throw new Error('amount not ready')
|
|
333
333
|
|
|
334
334
|
const walletClient = createWalletClient({
|
|
335
|
-
chain:chain,
|
|
336
|
-
transport:http(),
|
|
335
|
+
chain: chain,
|
|
336
|
+
transport: http(),
|
|
337
337
|
})
|
|
338
|
-
if(walletClient){
|
|
338
|
+
if (walletClient) {
|
|
339
339
|
|
|
340
340
|
const hash = await walletClient?.writeContract({
|
|
341
|
-
address:erc20Address as `0x${string}`,
|
|
342
|
-
abi:Erc20Abi as any,
|
|
343
|
-
functionName:'transfer',
|
|
344
|
-
args:[to,parseUnits(amount,decimalsQuery.data||18)],
|
|
341
|
+
address: erc20Address as `0x${string}`,
|
|
342
|
+
abi: Erc20Abi as any,
|
|
343
|
+
functionName: 'transfer',
|
|
344
|
+
args: [to, parseUnits(amount, decimalsQuery.data || 18)],
|
|
345
345
|
})
|
|
346
346
|
setHash(hash)
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
|
|
350
|
-
}catch(error:any){
|
|
350
|
+
} catch (error: any) {
|
|
351
351
|
console.error(error)
|
|
352
352
|
alert(error.message)
|
|
353
|
-
}finally {
|
|
353
|
+
} finally {
|
|
354
354
|
setLoading(false)
|
|
355
355
|
}
|
|
356
356
|
}
|
|
@@ -360,57 +360,57 @@ function ERC20() {
|
|
|
360
360
|
<div className={`flex-1 flex-wrap break-all`}>
|
|
361
361
|
To Address:
|
|
362
362
|
<input className="border px-[8px]" type={'text'} placeholder={'address'} value={to}
|
|
363
|
-
|
|
363
|
+
onChange={(e) => setTo(e.target.value)} />
|
|
364
364
|
</div>
|
|
365
365
|
<div className={`flex-1 flex-wrap break-all`}>
|
|
366
366
|
Amount:
|
|
367
367
|
<input className="border px-[8px]" type={'text'} placeholder={'amount'} value={amount}
|
|
368
|
-
|
|
368
|
+
onChange={(e) => setAmount(e.target.value)} />
|
|
369
369
|
</div>
|
|
370
370
|
|
|
371
371
|
</ButtonGroup>
|
|
372
372
|
|
|
373
373
|
<ButtonGroup title={"Transaction"}>
|
|
374
|
-
<Button size={"sm"} loading={loading} onClick={onSend} disabled={!to
|
|
374
|
+
<Button size={"sm"} loading={loading} onClick={onSend} disabled={!to || !amount || !walletReady}>Send</Button>
|
|
375
375
|
<div className={`flex-1 flex-wrap break-all`}>{hash}</div>
|
|
376
376
|
</ButtonGroup>
|
|
377
377
|
</>
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
function Approve(){
|
|
380
|
+
function Approve() {
|
|
381
381
|
const [to, setTo] = useState(address)
|
|
382
382
|
const [hash, setHash] = useState('')
|
|
383
383
|
const [amount, setAmount] = useState('0.0001')
|
|
384
|
-
const [loading,setLoading] = useState(false)
|
|
385
|
-
const onSend = async()=>{
|
|
386
|
-
try{
|
|
384
|
+
const [loading, setLoading] = useState(false)
|
|
385
|
+
const onSend = async () => {
|
|
386
|
+
try {
|
|
387
387
|
setLoading(true)
|
|
388
|
-
if(!walletReady) throw new Error('wallet not ready')
|
|
389
|
-
if(!evmAccount) throw new Error('account not ready')
|
|
390
|
-
if(!erc20Address) throw new Error('erc20Address not ready')
|
|
391
|
-
if(!to) throw new Error('to not ready')
|
|
392
|
-
if(!amount) throw new Error('amount not ready')
|
|
388
|
+
if (!walletReady) throw new Error('wallet not ready')
|
|
389
|
+
if (!evmAccount) throw new Error('account not ready')
|
|
390
|
+
if (!erc20Address) throw new Error('erc20Address not ready')
|
|
391
|
+
if (!to) throw new Error('to not ready')
|
|
392
|
+
if (!amount) throw new Error('amount not ready')
|
|
393
393
|
|
|
394
394
|
const walletClient = createWalletClient({
|
|
395
|
-
chain:chain,
|
|
396
|
-
transport:http(),
|
|
395
|
+
chain: chain,
|
|
396
|
+
transport: http(),
|
|
397
397
|
})
|
|
398
|
-
if(walletClient){
|
|
398
|
+
if (walletClient) {
|
|
399
399
|
|
|
400
400
|
const hash = await walletClient?.writeContract({
|
|
401
|
-
address:erc20Address as `0x${string}`,
|
|
402
|
-
abi:Erc20Abi as any,
|
|
403
|
-
functionName:'approve',
|
|
404
|
-
args:[to,parseUnits(amount,decimalsQuery.data||18)],
|
|
401
|
+
address: erc20Address as `0x${string}`,
|
|
402
|
+
abi: Erc20Abi as any,
|
|
403
|
+
functionName: 'approve',
|
|
404
|
+
args: [to, parseUnits(amount, decimalsQuery.data || 18)],
|
|
405
405
|
})
|
|
406
406
|
setHash(hash)
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
|
|
410
|
-
}catch(error:any){
|
|
410
|
+
} catch (error: any) {
|
|
411
411
|
console.error(error)
|
|
412
412
|
alert(error.message)
|
|
413
|
-
}finally {
|
|
413
|
+
} finally {
|
|
414
414
|
setLoading(false)
|
|
415
415
|
}
|
|
416
416
|
}
|
|
@@ -420,18 +420,18 @@ function ERC20() {
|
|
|
420
420
|
<div className={`flex-1 flex-wrap break-all`}>
|
|
421
421
|
To Address:
|
|
422
422
|
<input className="border px-[8px]" type={'text'} placeholder={'address'} value={to}
|
|
423
|
-
|
|
423
|
+
onChange={(e) => setTo(e.target.value)} />
|
|
424
424
|
</div>
|
|
425
425
|
<div className={`flex-1 flex-wrap break-all`}>
|
|
426
426
|
Amount:
|
|
427
427
|
<input className="border px-[8px]" type={'text'} placeholder={'amount'} value={amount}
|
|
428
|
-
|
|
428
|
+
onChange={(e) => setAmount(e.target.value)} />
|
|
429
429
|
</div>
|
|
430
430
|
|
|
431
431
|
</ButtonGroup>
|
|
432
432
|
|
|
433
433
|
<ButtonGroup title={"Transaction"}>
|
|
434
|
-
<Button size={"sm"} loading={loading} onClick={onSend} disabled={!to
|
|
434
|
+
<Button size={"sm"} loading={loading} onClick={onSend} disabled={!to || !amount || !walletReady}>Send</Button>
|
|
435
435
|
<div className={`flex-1 flex-wrap break-all`}>{hash}</div>
|
|
436
436
|
</ButtonGroup>
|
|
437
437
|
</>
|
|
@@ -441,7 +441,7 @@ function ERC20() {
|
|
|
441
441
|
<ButtonGroup title={"ERC20"}></ButtonGroup>
|
|
442
442
|
<ButtonGroup title={"Contract Address"}>
|
|
443
443
|
<input className="border px-[8px]" type={'text'} placeholder={'contract'} value={erc20Address}
|
|
444
|
-
|
|
444
|
+
onChange={(e) => setErc20Address(e.target.value)} />
|
|
445
445
|
</ButtonGroup>
|
|
446
446
|
<ButtonGroup title={"Info"}>
|
|
447
447
|
<div className={`flex-1 flex-wrap break-all`}>Symbol:{symbolQuery.data}</div>
|
|
@@ -451,7 +451,7 @@ function ERC20() {
|
|
|
451
451
|
<div className={`flex-1 flex-wrap break-all`}>{balanceQuery.data?.toString()}</div>
|
|
452
452
|
<div className={`flex-1 flex-wrap break-all`}>{balanceUnit} {symbolQuery.data}</div>
|
|
453
453
|
</ButtonGroup>
|
|
454
|
-
<Transfer/>
|
|
455
|
-
<Approve/>
|
|
454
|
+
<Transfer />
|
|
455
|
+
<Approve />
|
|
456
456
|
</div>
|
|
457
457
|
}
|