@matchain/matchid-sdk-react 0.1.42-alpha.1 → 0.1.42-alpha.11

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.
Files changed (71) hide show
  1. package/dist/assets/icon/index.d.mts +1 -1
  2. package/dist/assets/icon/index.d.ts +1 -1
  3. package/dist/chunk-HJ337PTX.mjs +4662 -0
  4. package/dist/chunk-HJ337PTX.mjs.map +1 -0
  5. package/dist/{chunk-U5KWO2YJ.mjs → chunk-PBNKRURB.mjs} +2 -2
  6. package/dist/chunk-SQIJR7RA.mjs +29 -0
  7. package/dist/chunk-SQIJR7RA.mjs.map +1 -0
  8. package/dist/components/index.d.mts +3 -2
  9. package/dist/components/index.d.ts +3 -2
  10. package/dist/components/index.js +676 -453
  11. package/dist/components/index.js.map +1 -1
  12. package/dist/components/index.mjs +4 -1
  13. package/dist/hooks/api/index.d.mts +2 -2
  14. package/dist/hooks/api/index.d.ts +2 -2
  15. package/dist/hooks/api/index.js +120 -76
  16. package/dist/hooks/api/index.js.map +1 -1
  17. package/dist/hooks/api/index.mjs +3 -2
  18. package/dist/hooks/index.d.mts +5 -2
  19. package/dist/hooks/index.d.ts +5 -2
  20. package/dist/hooks/index.js +328 -145
  21. package/dist/hooks/index.js.map +1 -1
  22. package/dist/hooks/index.mjs +2 -1
  23. package/dist/index-B2B4VJ-u.d.mts +139 -0
  24. package/dist/index-Bhnio7tx.d.ts +139 -0
  25. package/dist/index-BxS06a5O.d.ts +50 -0
  26. package/dist/{index-Dq9Swg8r.d.ts → index-Ca9nh_8s.d.ts} +1 -1
  27. package/dist/{index-COlsBC-b.d.mts → index-CmH9iRLd.d.mts} +25 -12
  28. package/dist/{index-C3KZYrtu.d.mts → index-DFZpfAfc.d.mts} +1 -1
  29. package/dist/{index-fS75Swm8.d.ts → index-DY_ReBra.d.ts} +25 -12
  30. package/dist/index-q5XDobUF.d.mts +50 -0
  31. package/dist/index.css +84 -4
  32. package/dist/index.d.mts +9 -4
  33. package/dist/index.d.ts +9 -4
  34. package/dist/index.js +1100 -614
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +6 -2
  37. package/dist/mpc-CTbBWHld.d.mts +20 -0
  38. package/dist/mpc-CTbBWHld.d.ts +20 -0
  39. package/dist/types/index.d.mts +3 -0
  40. package/dist/types/index.d.ts +3 -0
  41. package/dist/types/index.js +44 -0
  42. package/dist/types/index.js.map +1 -0
  43. package/dist/types/index.mjs +10 -0
  44. package/dist/types/index.mjs.map +1 -0
  45. package/dist/types-CVwZEgQ0.d.mts +244 -0
  46. package/dist/types-CVwZEgQ0.d.ts +244 -0
  47. package/example/package.json +1 -0
  48. package/example/src/App.tsx +56 -27
  49. package/example/src/abi/erc20.json +222 -0
  50. package/example/src/components/ButtonGroup/index.tsx +10 -0
  51. package/example/src/components/Login/index.tsx +2 -2
  52. package/example/src/components/RoutePrivate/index.tsx +4 -3
  53. package/example/src/config/chains/index.ts +2 -0
  54. package/example/src/config/chains/matchMain.ts +27 -0
  55. package/example/src/config/chains/matchTest.ts +33 -0
  56. package/example/src/config/index.ts +6 -2
  57. package/example/src/pages/User/components/BindListModal.tsx +10 -0
  58. package/example/src/pages/User/components/PohListModal.tsx +10 -0
  59. package/example/src/pages/User/components/QueryDisplay.tsx +25 -0
  60. package/example/src/pages/{User.tsx → User/index.tsx} +55 -84
  61. package/example/src/pages/Wallet.tsx +258 -43
  62. package/example/src/store/useLocalStore.ts +51 -0
  63. package/example/tsconfig.json +1 -0
  64. package/package.json +7 -2
  65. package/dist/chunk-SBOIXOAW.mjs +0 -4197
  66. package/dist/chunk-SBOIXOAW.mjs.map +0 -1
  67. package/dist/index-BrdP6eg5.d.ts +0 -93
  68. package/dist/index-D7bNSBwl.d.mts +0 -93
  69. package/dist/types.d-CLO_WLka.d.mts +0 -176
  70. package/dist/types.d-CLO_WLka.d.ts +0 -176
  71. /package/dist/{chunk-U5KWO2YJ.mjs.map → chunk-PBNKRURB.mjs.map} +0 -0
@@ -1,32 +1,57 @@
1
- import React, {useEffect, useState} from "react";
1
+ import React, {useEffect, useMemo, useState} from "react";
2
2
  import {MatchProvider} from "@matchain/matchid-sdk-react";
3
- import {BrowserRouter as Router, Routes, Route, Link} from 'react-router-dom';
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
9
  import {LocaleList} from "@/config";
10
+ import {LocaleType} from "@matchain/matchid-sdk-react/types";
11
+ import {useUserInfo} from "@matchain/matchid-sdk-react/hooks";
12
+ import RoutePrivate from "@/components/RoutePrivate";
13
+ import useLocalStore from "@/store/useLocalStore";
10
14
 
11
- const getState = () => {
12
- if (window.localStorage.getItem('match-local')) {
13
- const state = JSON.parse(window.localStorage.getItem('match-local') as string)
14
- return state.state
15
- }
16
- return null
15
+
16
+ function Nav() {
17
+ const {isLogin} = useUserInfo()
18
+ const location = useLocation()
19
+ const menus = useMemo(() => {
20
+ const list: {
21
+ name: string,
22
+ url: string
23
+ onActive: boolean
24
+ hidden?: boolean
25
+ }[] = [
26
+ {
27
+ name: 'Home',
28
+ url: '/',
29
+ onActive: location.pathname === '/'
30
+ },
31
+ {
32
+ name: 'User',
33
+ url: '/user',
34
+ onActive: location.pathname === '/user'
35
+ },
36
+ {
37
+ name: 'Wallet',
38
+ url: '/wallet',
39
+ onActive: location.pathname === '/wallet',
40
+ hidden: !isLogin
41
+ }
42
+ ]
43
+ return list
44
+ }, [location.pathname, isLogin])
45
+ return <nav className={`text-2xl mb-5 p-2 text-red-600 flex gap-10`}>
46
+ {menus.map((menu) => {
47
+ return <Link key={menu.url} to={menu.url}
48
+ className={`text-2xl ${menu.onActive ? 'text-red-600' : 'text-gray-400'}`}>{menu.name}</Link>
49
+ })}
50
+ </nav>
17
51
  }
18
52
 
19
53
  function App() {
20
- const state = getState()
21
- const [appid, setAppid] = useState(state?.appid || '')
22
- const [locale,setLocale] = useState(window.localStorage.getItem('locale')||'en')
23
- useEffect(()=>{
24
- window.localStorage.setItem('locale',locale)
25
- },[locale])
26
- const [endpoints, setEndpoints] = useState<{
27
- auth: string,
28
- back: string
29
- }>(state?.endpoints)
54
+ const {appid, setAppid,locale,setLocale,endpoints, setEndpoints}= useLocalStore()
30
55
 
31
56
  return <MatchProvider appid={appid} endpoints={endpoints} locale={locale} events={{
32
57
  onLogin: (data) => {
@@ -36,6 +61,9 @@ function App() {
36
61
  console.log('events.onLogout')
37
62
  }
38
63
  }}
64
+ wallet={{
65
+ type:"UserPasscode"
66
+ }}
39
67
  >
40
68
  <Router>
41
69
  <div className={`mb-2 p-2 flex gap-2 flex-col`}>
@@ -60,21 +88,22 @@ function App() {
60
88
  </div>
61
89
  <div>
62
90
  <label>Locale:</label>
63
- <select onChange={(ele) => {setLocale(ele.target.value)}} value={locale}>
64
- {LocaleList.map((item)=><option key={item} value={item}>{item}</option>)}
91
+ <select onChange={(ele) => {
92
+ setLocale(ele.target.value as LocaleType)
93
+ }} value={locale}>
94
+ {LocaleList.map((item) => <option key={item} value={item}>{item}</option>)}
65
95
  </select>
66
96
  </div>
67
97
  </div>
68
- <nav className={`text-2xl mb-5 p-2 text-red-600 flex gap-10`}>
69
- <Link to="/">Home</Link>
70
- <Link to="/user">User</Link>
71
- <Link to="/wallet">Wallet</Link>
72
- </nav>
98
+ <Nav/>
73
99
  <div className={`p-4`}>
74
100
  <Routes>
75
101
  <Route path="/" element={<Home/>}/>
76
- <Route path="/user" element={<User/>}/>
77
- <Route path="/wallet" element={<Wallet/>}/>
102
+
103
+ <Route element={<RoutePrivate/>}>
104
+ <Route path="/user" element={<User/>}/>
105
+ <Route path="/wallet" element={<Wallet/>}/>
106
+ </Route>
78
107
  </Routes>
79
108
  </div>
80
109
  </Router>
@@ -0,0 +1,222 @@
1
+ [
2
+ {
3
+ "constant": true,
4
+ "inputs": [],
5
+ "name": "name",
6
+ "outputs": [
7
+ {
8
+ "name": "",
9
+ "type": "string"
10
+ }
11
+ ],
12
+ "payable": false,
13
+ "stateMutability": "view",
14
+ "type": "function"
15
+ },
16
+ {
17
+ "constant": false,
18
+ "inputs": [
19
+ {
20
+ "name": "_spender",
21
+ "type": "address"
22
+ },
23
+ {
24
+ "name": "_value",
25
+ "type": "uint256"
26
+ }
27
+ ],
28
+ "name": "approve",
29
+ "outputs": [
30
+ {
31
+ "name": "",
32
+ "type": "bool"
33
+ }
34
+ ],
35
+ "payable": false,
36
+ "stateMutability": "nonpayable",
37
+ "type": "function"
38
+ },
39
+ {
40
+ "constant": true,
41
+ "inputs": [],
42
+ "name": "totalSupply",
43
+ "outputs": [
44
+ {
45
+ "name": "",
46
+ "type": "uint256"
47
+ }
48
+ ],
49
+ "payable": false,
50
+ "stateMutability": "view",
51
+ "type": "function"
52
+ },
53
+ {
54
+ "constant": false,
55
+ "inputs": [
56
+ {
57
+ "name": "_from",
58
+ "type": "address"
59
+ },
60
+ {
61
+ "name": "_to",
62
+ "type": "address"
63
+ },
64
+ {
65
+ "name": "_value",
66
+ "type": "uint256"
67
+ }
68
+ ],
69
+ "name": "transferFrom",
70
+ "outputs": [
71
+ {
72
+ "name": "",
73
+ "type": "bool"
74
+ }
75
+ ],
76
+ "payable": false,
77
+ "stateMutability": "nonpayable",
78
+ "type": "function"
79
+ },
80
+ {
81
+ "constant": true,
82
+ "inputs": [],
83
+ "name": "decimals",
84
+ "outputs": [
85
+ {
86
+ "name": "",
87
+ "type": "uint8"
88
+ }
89
+ ],
90
+ "payable": false,
91
+ "stateMutability": "view",
92
+ "type": "function"
93
+ },
94
+ {
95
+ "constant": true,
96
+ "inputs": [
97
+ {
98
+ "name": "_owner",
99
+ "type": "address"
100
+ }
101
+ ],
102
+ "name": "balanceOf",
103
+ "outputs": [
104
+ {
105
+ "name": "balance",
106
+ "type": "uint256"
107
+ }
108
+ ],
109
+ "payable": false,
110
+ "stateMutability": "view",
111
+ "type": "function"
112
+ },
113
+ {
114
+ "constant": true,
115
+ "inputs": [],
116
+ "name": "symbol",
117
+ "outputs": [
118
+ {
119
+ "name": "",
120
+ "type": "string"
121
+ }
122
+ ],
123
+ "payable": false,
124
+ "stateMutability": "view",
125
+ "type": "function"
126
+ },
127
+ {
128
+ "constant": false,
129
+ "inputs": [
130
+ {
131
+ "name": "_to",
132
+ "type": "address"
133
+ },
134
+ {
135
+ "name": "_value",
136
+ "type": "uint256"
137
+ }
138
+ ],
139
+ "name": "transfer",
140
+ "outputs": [
141
+ {
142
+ "name": "",
143
+ "type": "bool"
144
+ }
145
+ ],
146
+ "payable": false,
147
+ "stateMutability": "nonpayable",
148
+ "type": "function"
149
+ },
150
+ {
151
+ "constant": true,
152
+ "inputs": [
153
+ {
154
+ "name": "_owner",
155
+ "type": "address"
156
+ },
157
+ {
158
+ "name": "_spender",
159
+ "type": "address"
160
+ }
161
+ ],
162
+ "name": "allowance",
163
+ "outputs": [
164
+ {
165
+ "name": "",
166
+ "type": "uint256"
167
+ }
168
+ ],
169
+ "payable": false,
170
+ "stateMutability": "view",
171
+ "type": "function"
172
+ },
173
+ {
174
+ "payable": true,
175
+ "stateMutability": "payable",
176
+ "type": "fallback"
177
+ },
178
+ {
179
+ "anonymous": false,
180
+ "inputs": [
181
+ {
182
+ "indexed": true,
183
+ "name": "owner",
184
+ "type": "address"
185
+ },
186
+ {
187
+ "indexed": true,
188
+ "name": "spender",
189
+ "type": "address"
190
+ },
191
+ {
192
+ "indexed": false,
193
+ "name": "value",
194
+ "type": "uint256"
195
+ }
196
+ ],
197
+ "name": "Approval",
198
+ "type": "event"
199
+ },
200
+ {
201
+ "anonymous": false,
202
+ "inputs": [
203
+ {
204
+ "indexed": true,
205
+ "name": "from",
206
+ "type": "address"
207
+ },
208
+ {
209
+ "indexed": true,
210
+ "name": "to",
211
+ "type": "address"
212
+ },
213
+ {
214
+ "indexed": false,
215
+ "name": "value",
216
+ "type": "uint256"
217
+ }
218
+ ],
219
+ "name": "Transfer",
220
+ "type": "event"
221
+ }
222
+ ]
@@ -0,0 +1,10 @@
1
+ import {PropsWithChildren} from "react";
2
+
3
+ export default function ButtonGroup({children,title}: PropsWithChildren&{
4
+ title?: string
5
+ }) {
6
+ return <div className={`flex gap-[16px] flex-wrap items-center`}>
7
+ {title&&<div className={`text-xl`}>{title}</div>}
8
+ {children}
9
+ </div>
10
+ }
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import {Hooks,Components} from "@matchain/matchid-sdk-react";
3
- import {LoginMethod, WalletMethod} from "@/config";
3
+ import {LoginMethod, WalletList} from "@/config";
4
4
  import {LoginMethodType} from "../../../../src/types/types";
5
5
  const { useUserInfo} = Hooks
6
6
  const {EmailModal,LoginModal,LoginBox,LoginPanel} = Components
@@ -38,7 +38,7 @@ export default function Login(){
38
38
  }}/>
39
39
 
40
40
 
41
- <LoginModal isOpen={loginOpen} walletMethods={WalletMethod} onClose={() => setLoginOpen(false)} methods={[
41
+ <LoginModal isOpen={loginOpen} walletMethods={WalletList} onClose={() => setLoginOpen(false)} methods={[
42
42
  'telegram',
43
43
  'twitter',
44
44
  'discord',
@@ -1,9 +1,10 @@
1
- import React, {PropsWithChildren} from "react";
1
+ import React from "react";
2
2
  import Login from "../Login";
3
3
  import {Hooks} from "@matchain/matchid-sdk-react";
4
+ import { Outlet} from 'react-router-dom';
4
5
 
5
- export default function RoutePrivate({children}: PropsWithChildren) {
6
+ export default function RoutePrivate() {
6
7
  const {isLogin} = Hooks.useUserInfo()
7
8
 
8
- return isLogin ? <>{children}</> : <Login/>
9
+ return isLogin ? <Outlet/> : <Login/>
9
10
  }
@@ -0,0 +1,2 @@
1
+ export {matchMain} from "./matchMain"
2
+ export {matchTest} from "./matchTest"
@@ -0,0 +1,27 @@
1
+ import {defineChain} from "viem";
2
+
3
+ export const matchMain = /*#__PURE__*/ defineChain({
4
+ id: 698,
5
+ name: "Matchain",
6
+ nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ["https://rpc.matchain.io"],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: "Matchscan",
15
+ url: "https://matchscan.io/",
16
+ apiUrl: "https://matchscan.io/api",
17
+ },
18
+ },
19
+ iconUrl: "https://matchscan.io/static/identicon_logos/blockies.png",
20
+ contracts: {
21
+ multicall3: {
22
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
23
+ }
24
+ },
25
+ // testnet: true,
26
+ });
27
+
@@ -0,0 +1,33 @@
1
+
2
+ import { defineChain } from "viem"
3
+
4
+ export const matchTest = /*#__PURE__*/ defineChain({
5
+ id: 699,
6
+ name: "MatchTest",
7
+ nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
8
+ rpcUrls: {
9
+ default: {
10
+ http: ["https://testnet-rpc.matchain.io"],
11
+ },
12
+ },
13
+ blockExplorers: {
14
+ default: {
15
+ name: "Matchscan",
16
+ url: "https://testnet.matchscan.io/",
17
+ apiUrl: "https://testnet.matchscan.io/api",
18
+ },
19
+ },
20
+ iconUrl: "https://testnet.matchscan.io/static/identicon_logos/blockies.png",
21
+ contracts: {
22
+ multicall3: {
23
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
24
+ blockCreated: 751532,
25
+ },
26
+ ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
27
+ ensUniversalResolver: {
28
+ address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
29
+ blockCreated: 5_317_080,
30
+ },
31
+ },
32
+ // testnet: true,
33
+ });
@@ -1,4 +1,4 @@
1
- import {WalletType} from "../../../src/types/types";
1
+ import {LoginMethodType, WalletType,RecommendLoginMethodType,OtherLoginMethodType} from "@matchain/matchid-sdk-react/types";
2
2
 
3
3
  export const LoginMethod = [
4
4
  'evm',
@@ -22,8 +22,12 @@ export const LocaleList = [
22
22
  export const CEXList = [
23
23
  "Gate", "Coinbase", "Kucoin", 'Bitget', 'OKX', 'Bybit', 'Binance']
24
24
 
25
- export const WalletMethod:WalletType[] = ["evm","sol","btc","tron","ton"]
25
+ export const WalletList:WalletType[] = [
26
+ 'btc', 'sol', 'evm', 'tron',"ton"
27
+ ]
28
+ export const LoginMethodList : OtherLoginMethodType[] = ['twitter' , 'discord', 'github', 'telegram' ,'linkedin' , 'facebook' ,'youtube']
26
29
 
30
+ export const RecommendLoginMethodList:RecommendLoginMethodType[] = ["wallet","email","google"]
27
31
 
28
32
  export const LOGIN_METHOD_MAP = {
29
33
  email: 'Email',
@@ -0,0 +1,10 @@
1
+ import { ModalWithHeader } from '@matchain/matchid-sdk-react/components';
2
+ import React from "react";
3
+ import QueryDisplay from "@/pages/User/components/QueryDisplay";
4
+ import {Api} from "@matchain/matchid-sdk-react/index";
5
+ export default function BindListModal({isOpen, onClose}: {isOpen: boolean, onClose: () => void}) {
6
+ const bindListQuery = Api.bind.useBindList()
7
+ return <ModalWithHeader isOpen={isOpen} onClose={onClose} title={"BindListQuery"}>
8
+ <QueryDisplay query={bindListQuery} />
9
+ </ModalWithHeader>
10
+ }
@@ -0,0 +1,10 @@
1
+ import { ModalWithHeader } from '@matchain/matchid-sdk-react/components';
2
+ import React from "react";
3
+ import QueryDisplay from "@/pages/User/components/QueryDisplay";
4
+ import {Api} from "@matchain/matchid-sdk-react/index";
5
+ export default function PohListModal({isOpen, onClose}: {isOpen: boolean, onClose: () => void}) {
6
+ const pohListQuery = Api.poh.usePohList()
7
+ return <ModalWithHeader isOpen={isOpen} onClose={onClose} title={"PohListQuery"}>
8
+ <QueryDisplay query={pohListQuery} />
9
+ </ModalWithHeader>
10
+ }
@@ -0,0 +1,25 @@
1
+ import {Button} from "@matchain/matchid-sdk-react/components";
2
+ import React from "react";
3
+
4
+ export default function QueryDisplay(
5
+ {
6
+ query
7
+ }: {
8
+ query: any
9
+ }
10
+ ) {
11
+ const keys = Object.keys(query)
12
+ return <div className={`max-h-[60vw] overflow-scroll`}>
13
+ {keys.map((key) => {
14
+ return <div key={key} className={`flex gap-[12px]`}>
15
+ <div className={"w-[110px] break-all"}>{key}</div>
16
+ <div className={`flex-1 flex-wrap break-all`}>{
17
+ typeof query[key] === 'function' ? <Button size="sm" onClick={() => {
18
+ query[key]()
19
+ }}>Run</Button> :
20
+ JSON.stringify(query[key])}</div>
21
+ </div>
22
+ })}
23
+ </div>
24
+
25
+ }