@matchain/matchid-sdk-react 0.1.42-alpha.16 → 0.1.42-alpha.2

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-WCS3X2LC.mjs → chunk-2YN5Y3SM.mjs} +2 -2
  4. package/dist/chunk-PZPEWHBV.mjs +4251 -0
  5. package/dist/chunk-PZPEWHBV.mjs.map +1 -0
  6. package/dist/components/index.d.mts +2 -3
  7. package/dist/components/index.d.ts +2 -3
  8. package/dist/components/index.js +486 -770
  9. package/dist/components/index.js.map +1 -1
  10. package/dist/components/index.mjs +3 -8
  11. package/dist/hooks/api/index.d.mts +2 -2
  12. package/dist/hooks/api/index.d.ts +2 -2
  13. package/dist/hooks/api/index.js +78 -137
  14. package/dist/hooks/api/index.js.map +1 -1
  15. package/dist/hooks/api/index.mjs +2 -3
  16. package/dist/hooks/index.d.mts +2 -5
  17. package/dist/hooks/index.d.ts +2 -5
  18. package/dist/hooks/index.js +158 -362
  19. package/dist/hooks/index.js.map +1 -1
  20. package/dist/hooks/index.mjs +1 -2
  21. package/dist/index-B4YpKSY3.d.ts +94 -0
  22. package/dist/{index-CLvQH5gM.d.ts → index-CxY3u9Rv.d.ts} +12 -32
  23. package/dist/{index-DlhAHm_s.d.mts → index-DCReY5T2.d.mts} +12 -32
  24. package/dist/{index-Ca9nh_8s.d.ts → index-DbjibQ5d.d.mts} +1 -1
  25. package/dist/{index-DFZpfAfc.d.mts → index-GcpJCj6O.d.ts} +1 -1
  26. package/dist/index-_k6h9w0P.d.mts +94 -0
  27. package/dist/index.css +4 -84
  28. package/dist/index.d.mts +5 -9
  29. package/dist/index.d.ts +5 -9
  30. package/dist/index.js +669 -1183
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +2 -6
  33. package/dist/types.d-DwF-Pkvh.d.mts +179 -0
  34. package/dist/types.d-DwF-Pkvh.d.ts +179 -0
  35. package/example/package.json +0 -1
  36. package/example/src/App.tsx +28 -54
  37. package/example/src/components/Login/index.tsx +2 -2
  38. package/example/src/components/RoutePrivate/index.tsx +3 -4
  39. package/example/src/config/index.ts +2 -7
  40. package/example/src/pages/{User/index.tsx → User.tsx} +84 -55
  41. package/example/src/pages/Wallet.tsx +43 -258
  42. package/example/tsconfig.json +0 -1
  43. package/package.json +2 -7
  44. package/dist/chunk-SQIJR7RA.mjs +0 -29
  45. package/dist/chunk-SQIJR7RA.mjs.map +0 -1
  46. package/dist/chunk-UCIEZ3XI.mjs +0 -4747
  47. package/dist/chunk-UCIEZ3XI.mjs.map +0 -1
  48. package/dist/index-Bluim2ZP.d.mts +0 -143
  49. package/dist/index-BxS06a5O.d.ts +0 -50
  50. package/dist/index-EqksEEto.d.ts +0 -143
  51. package/dist/index-q5XDobUF.d.mts +0 -50
  52. package/dist/mpc-CTbBWHld.d.mts +0 -20
  53. package/dist/mpc-CTbBWHld.d.ts +0 -20
  54. package/dist/types/index.d.mts +0 -3
  55. package/dist/types/index.d.ts +0 -3
  56. package/dist/types/index.js +0 -44
  57. package/dist/types/index.js.map +0 -1
  58. package/dist/types/index.mjs +0 -10
  59. package/dist/types/index.mjs.map +0 -1
  60. package/dist/types-CVwZEgQ0.d.mts +0 -244
  61. package/dist/types-CVwZEgQ0.d.ts +0 -244
  62. package/example/src/abi/erc20.json +0 -222
  63. package/example/src/components/ButtonGroup/index.tsx +0 -10
  64. package/example/src/config/chains/index.ts +0 -2
  65. package/example/src/config/chains/matchMain.ts +0 -27
  66. package/example/src/config/chains/matchTest.ts +0 -33
  67. package/example/src/pages/User/components/BindListModal.tsx +0 -10
  68. package/example/src/pages/User/components/PohListModal.tsx +0 -10
  69. package/example/src/pages/User/components/QueryDisplay.tsx +0 -25
  70. package/example/src/store/useLocalStore.ts +0 -51
  71. /package/dist/{chunk-WCS3X2LC.mjs.map → chunk-2YN5Y3SM.mjs.map} +0 -0
@@ -1,18 +1,47 @@
1
- import React, {useState} from "react";
2
- import {CEXList, LOGIN_METHOD_MAP, LoginMethod, LoginMethodList, RecommendLoginMethodList, WalletList} from "@/config";
3
- import {CEXType, LoginMethodType} from "@matchain/matchid-sdk-react/types";
4
- import {useMatchEvents, useUserInfo, useWallet} from "@matchain/matchid-sdk-react/hooks";
5
- import {
1
+ import {Hooks, Components, Api} from "@matchain/matchid-sdk-react"
2
+ import React from "react";
3
+ import RoutePrivate from "../components/RoutePrivate";
4
+ import {CEXList, LOGIN_METHOD_MAP, LoginMethod, WalletMethod} from "@/config";
5
+ import {CEXType, LoginMethodType} from "../../../src/types/types";
6
+
7
+ const {useMatchEvents, useUserInfo, useWallet} = Hooks
8
+ const {
6
9
  LoginButton,
7
10
  UsernameModal,
8
11
  PasswordModal,
9
- } from "@matchain/matchid-sdk-react/components";
10
- import BindListModal from "@/pages/User/components/BindListModal";
11
- import PohListModal from "@/pages/User/components/PohListModal";
12
- import ButtonGroup from "@/components/ButtonGroup";
12
+ Button,
13
+ } = Components
14
+
15
+ function QueryDisplay(
16
+ {
17
+ name,
18
+ query
19
+ }: {
20
+ name: string
21
+ query: any
22
+ }
23
+ ) {
24
+ const keys = Object.keys(query)
25
+ return <div>
26
+ <div className={`font-bold text-lg`}>{name}</div>
27
+ {keys.map((key) => {
28
+ return <div key={key} className={`flex gap-[20px]`}>
29
+ <div className={"w-[200px]"}>{key}</div>
30
+ <div className={`flex-1 flex-wrap break-all`}>{
31
+ typeof query[key] === 'function' ? <Button size="sm" onClick={() => {
32
+ query[key]()
33
+ }}>Run</Button> :
34
+ JSON.stringify(query[key])}</div>
35
+ </div>
36
+ })}
37
+ </div>
13
38
 
39
+ }
14
40
 
15
41
  function LoginContent() {
42
+ const bindListQuery = Api.bind.useBindList()
43
+ const pohListQuery = Api.poh.usePohList()
44
+
16
45
  const {
17
46
  token,
18
47
  logout,
@@ -25,9 +54,8 @@ function LoginContent() {
25
54
  bindCex,
26
55
  getAuthInfo
27
56
  } = useUserInfo();
28
- const [usernameOpen, setUsernameOpen] = useState(false)
29
- const [passwordOpen, setPasswordOpen] = useState(false)
30
- const [modal, setModal] = useState<'bindList' | 'pohList' | ''>('')
57
+ const [usernameOpen, setUsernameOpen] = React.useState(false)
58
+ const [passwordOpen, setPasswordOpen] = React.useState(false)
31
59
  const refreshOv = async () => {
32
60
  await refreshOverview()
33
61
  alert('refreshed')
@@ -42,30 +70,25 @@ function LoginContent() {
42
70
  }
43
71
  }
44
72
 
73
+ const onGetInfo = async (method: string) => {
74
+ try {
75
+ const res = await getAuthInfo(method)
76
+ console.log('getAuthInfo', res)
77
+ } catch (e) {
78
+ console.error('getAuthInfo', e)
79
+ }
80
+ }
81
+
45
82
  return <div className={`flex flex-col gap-[10px]`}>
46
83
  <h1 className={`text-2xl`}>You are already logged in</h1>
47
84
  <div className={`text-ellipsis break-words`}>token:{token}</div>
48
85
  <div className={`text-ellipsis break-words`}>username:{username}</div>
49
86
  <div className={`text-ellipsis break-words`}>did:{did}</div>
50
87
  <div className={`text-ellipsis break-words`}>address:{address}</div>
51
-
52
- <ButtonGroup title={"User"}>
88
+ <div className={`flex gap-[20px]`}>
53
89
  <button className={`bg-gray-300 p-1 rounded`}
54
90
  onClick={() => setUsernameOpen(true)}>Set username
55
91
  </button>
56
-
57
- <button className={`bg-gray-300 p-1 rounded mr-5`}
58
- onClick={() => setPasswordOpen(true)}>Set Password
59
- </button>
60
- <button className={`bg-gray-300 p-1 rounded`}
61
- onClick={onAuth}>Third party auth
62
- </button>
63
- <button className={`bg-gray-300 p-1 rounded`}
64
- onClick={refreshOv}>Refresh Overview
65
- </button>
66
- <button className={`bg-gray-300 p-1 rounded`}
67
- onClick={logout}>Logout
68
- </button>
69
92
  <UsernameModal isOpen={usernameOpen} onClose={() => setUsernameOpen(false)} onBack={() => {
70
93
  console.log('set username modal back event')
71
94
  setUsernameOpen(false)
@@ -73,6 +96,9 @@ function LoginContent() {
73
96
  alert('set username success')
74
97
  setUsernameOpen(false)
75
98
  }}/>
99
+ <button className={`bg-gray-300 p-1 rounded mr-5`}
100
+ onClick={() => setPasswordOpen(true)}>Set Password
101
+ </button>
76
102
  <PasswordModal isOpen={passwordOpen} onClose={() => setPasswordOpen(false)} onBack={() => {
77
103
  console.log('set password modal back event')
78
104
  setPasswordOpen(false)
@@ -80,8 +106,11 @@ function LoginContent() {
80
106
  alert('set password success')
81
107
  setPasswordOpen(false)
82
108
  }}/>
83
- </ButtonGroup>
84
- <ButtonGroup title={"Bind"}>
109
+ </div>
110
+ <div className={`flex gap-[20px] flex-wrap`}>
111
+ <div>
112
+ Bind
113
+ </div>
85
114
  {
86
115
  LoginMethod.map((method) => {
87
116
  return <button key={method} className={`bg-gray-300 p-1 capitalize rounded`}
@@ -89,37 +118,41 @@ function LoginContent() {
89
118
  </button>
90
119
  })
91
120
  }
92
- </ButtonGroup>
93
- <ButtonGroup title={"Bind CEX"}>
121
+ </div>
122
+ <div className={`flex gap-[20px] flex-wrap`}>
123
+ <div>
124
+ GetAuthInfo
125
+ </div>
94
126
  {
95
- CEXList.map((method) => {
96
- return <button key={method} className={`bg-gray-300 p-1 capitalize rounded`}
97
- onClick={() => bindCex(method as CEXType)}>CEX {method}
98
- </button>
127
+ Object.keys(LOGIN_METHOD_MAP).map((method:string ) => {
128
+ return <button key={method} className={`bg-gray-300 p-1 rounded`}
129
+ onClick={async() => onGetInfo(LOGIN_METHOD_MAP[method as keyof typeof LOGIN_METHOD_MAP])}>{method}</button>
99
130
  })
100
131
  }
101
- </ButtonGroup>
102
- <ButtonGroup title={"getAuthInfo"}>
132
+ </div>
133
+ <div className={`flex gap-[20px] flex-wrap`}>
103
134
  {
104
- Object.keys(LOGIN_METHOD_MAP).map((method) => {
135
+ CEXList.map((method) => {
105
136
  return <button key={method} className={`bg-gray-300 p-1 capitalize rounded`}
106
- onClick={() => getAuthInfo(method as keyof typeof LOGIN_METHOD_MAP)}>{LOGIN_METHOD_MAP[method as keyof typeof LOGIN_METHOD_MAP]}
137
+ onClick={() => bindCex(method as CEXType)}>CEX {method}
107
138
  </button>
108
139
  })
109
140
  }
110
- </ButtonGroup>
111
-
112
- <ButtonGroup title={"QueryList"}>
141
+ </div>
142
+ <div className={`flex gap-[20px]`}>
113
143
  <button className={`bg-gray-300 p-1 rounded`}
114
- onClick={() => setModal('bindList')}>BindList
144
+ onClick={onAuth}>Third party auth
115
145
  </button>
116
146
  <button className={`bg-gray-300 p-1 rounded`}
117
- onClick={() => setModal('pohList')}>PohList
147
+ onClick={refreshOv}>Refresh Overview
118
148
  </button>
119
- </ButtonGroup>
149
+ <button className={`bg-gray-300 p-1 rounded`}
150
+ onClick={logout}>Logout
151
+ </button>
152
+ </div>
120
153
 
121
- <BindListModal isOpen={modal == 'bindList'} onClose={() => setModal('')}/>
122
- <PohListModal isOpen={modal == 'pohList'} onClose={() => setModal('')}/>
154
+ <QueryDisplay query={bindListQuery} name={"BindListQuery"}/>
155
+ <QueryDisplay query={pohListQuery} name={"PohListQuery"}/>
123
156
  </div>
124
157
 
125
158
  }
@@ -141,15 +174,11 @@ export default function User() {
141
174
  <div className={`font-bold text-lg`}>LoginButton</div>
142
175
 
143
176
  <div className={`bg-gray-100 p-5 mt-5`}>
144
- <LoginButton
145
- methods={LoginMethodList}
146
- recommendMethods={RecommendLoginMethodList}
147
- popoverPosition={"left"}
148
- walletMethods={WalletList}
149
- />
177
+ <LoginButton methods={[ "twitter", 'facebook',"discord","github","youtube","telegram"]} popoverPosition={"left"} walletMethods={WalletMethod}/>
150
178
  </div>
151
-
152
- <LoginContent/>
179
+ <RoutePrivate>
180
+ <LoginContent/>
181
+ </RoutePrivate>
153
182
 
154
183
 
155
184
  </div>
@@ -1,92 +1,23 @@
1
- import {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
- import {
5
- createPublicClient,
6
- formatUnits,
7
- parseUnits,
8
- parseGwei,
9
- Account,
10
- Transport,
11
- HttpTransportConfig, http, TransactionSerializable
12
- } from "viem";
1
+ import {Hooks} from "@matchain/matchid-sdk-react"
2
+ import React, {useState} from "react";
3
+ import {createPublicClient, http, formatUnits, parseUnits, createWalletClient, parseGwei, Account} from "viem";
13
4
  import {useQuery} from "@tanstack/react-query";
14
- import {
15
- mainnet,
16
- arbitrum,
17
- arbitrumGoerli,
18
- arbitrumNova,
19
- arbitrumSepolia,
20
- avalanche,
21
- base,
22
- baseSepolia,
23
- baseGoerli,
24
- bsc,
25
- bscTestnet,
26
- goerli,
27
- linea,
28
- lineaGoerli,
29
- lineaSepolia,
30
- sepolia,
31
- polygonMumbai,
32
- polygon,
33
- polygonAmoy,
34
- zkSync,
35
- } from 'viem/chains';
36
- import {matchMain, matchTest} from "@/config/chains";
37
- import useLocalStore from "@/store/useLocalStore";
38
- import ButtonGroup from "@/components/ButtonGroup";
39
- import Erc20Abi from "@/abi/erc20.json";
40
- import type {Abi} from "abitype";
5
+ import {bscTestnet} from 'viem/chains';
41
6
 
42
- const chainList = [
43
- mainnet,
44
- bsc,
45
- bscTestnet,
46
- matchMain,
47
- matchTest,
48
- arbitrum,
49
- arbitrumGoerli,
50
- arbitrumNova,
51
- arbitrumSepolia,
52
- avalanche,
53
- base,
54
- baseSepolia,
55
- baseGoerli,
56
- goerli,
57
- linea,
58
- lineaGoerli,
59
- lineaSepolia,
60
- sepolia,
61
- polygonMumbai,
62
- polygon,
63
- polygonAmoy,
64
- zkSync,
65
- ]
7
+ const {useWallet} = Hooks
66
8
 
67
9
  export default function Wallet() {
68
-
69
- const {initChainId, setInitChainId} = useLocalStore()
70
-
71
10
  const [message, setMessage] = useState('hello')
72
11
  const [toAddress, setToAddress] = useState('')
73
12
  const [toAmount, setToAmount] = useState('0.0001')
74
13
  const [data, setToData] = useState('0x')
75
- const {address, evmAccount, createWalletClient, walletReady} = useWallet()
76
- const chain = chainList.find((chain) => chain.id === initChainId)
77
-
14
+ const {address, evmAccount} = useWallet()
15
+ const chain = bscTestnet
78
16
  const walletClient = createWalletClient({
79
17
  chain: chain,
80
18
  transport: http(),
81
- // account:evmAccount
82
19
  })
83
20
 
84
- useEffect(() => {
85
- if (address && !toAddress) {
86
- setToAddress(address)
87
- }
88
- }, [address, toAddress]);
89
-
90
21
 
91
22
  const [hash, setHash] = useState('')
92
23
  const [transactionSign, setTransactionSign] = useState('')
@@ -94,7 +25,7 @@ export default function Wallet() {
94
25
 
95
26
  const publicClient = createPublicClient({
96
27
  chain: chain,
97
- transport: http() as Transport,
28
+ transport: http(),
98
29
  });
99
30
 
100
31
  const balanceQuery = useQuery({
@@ -115,13 +46,7 @@ export default function Wallet() {
115
46
  }
116
47
  })
117
48
 
118
- useEffect(() => {
119
- gasPriceQuery.refetch()
120
- balanceQuery.refetch()
121
- }, [chain]);
122
-
123
49
  const onSign = async () => {
124
- if (!walletClient) return;
125
50
  const res = await walletClient.signMessage({
126
51
  message,
127
52
  account: evmAccount as Account
@@ -130,62 +55,43 @@ export default function Wallet() {
130
55
  }
131
56
 
132
57
  const onSignTransaction = async () => {
133
- if (!walletClient || !evmAccount) return
134
- try {
135
-
136
- const transaction = {
137
- to: toAddress as `0x${string}`,
138
- value: parseUnits(toAmount, 18),
139
- data: data as `0x${string}`,
140
- chain: chain
141
- }
142
- const request = await walletClient.prepareTransactionRequest(transaction)
143
- const res = await evmAccount.signTransaction!(request as TransactionSerializable)
144
- setTransactionSign(res)
145
- } catch (e) {
146
- console.error(e)
58
+ const transaction = {
59
+ account:evmAccount as Account,
60
+ to: toAddress as `0x${string}`,
61
+ value: parseUnits(toAmount, 18),
62
+ data: data as `0x${string}`,
147
63
  }
64
+ const request = await walletClient.prepareTransactionRequest(transaction)
65
+ const res = await walletClient.signTransaction(request)
66
+ setTransactionSign(res)
148
67
  }
149
68
 
150
69
  const onSendTransaction = async () => {
151
- if (!walletClient) return
152
70
  const res = await walletClient.sendTransaction({
153
- // account:evmAccount as Account,
71
+ account:evmAccount as Account,
154
72
  to: toAddress as `0x${string}`,
155
73
  value: parseUnits(toAmount, 18),
156
74
  data: data as `0x${string}`,
157
- chain: chain
158
75
  })
159
76
  setHash(res)
160
77
  }
161
78
 
162
79
 
163
80
  return <div>
164
- <ButtonGroup title={"Wallet Ready"}>
165
- {walletReady ? 'Ready' : 'Not Ready'}
166
- </ButtonGroup>
167
- <ButtonGroup title={"CreateWalletClient Chain"}>
168
- <select value={initChainId} onChange={(e) => setInitChainId(parseInt(e.target.value))}>
169
- {chainList.map((chain, index) => {
170
- return <option key={index} value={chain.id}>{chain.name}({chain.id})</option>
171
- })}
172
- </select>
173
- </ButtonGroup>
174
- <ButtonGroup title={"Ethereum address"}>
175
- <div className={`flex-1 flex-wrap break-all`}>{address}</div>
176
- </ButtonGroup>
177
- <ButtonGroup title={"Signature Message"}>
178
- <input className="border px-[8px]" type={'text'} placeholder={'message'} value={message}
179
- onChange={(e) => setMessage(e.target.value)}/>
180
- <Button onClick={onSign} size={"sm"} disabled={!walletReady}>Sign message</Button>
181
- </ButtonGroup>
182
- <ButtonGroup title={"Signature Result"}>
183
- <div className={`flex-1 flex-wrap break-all`}>{signature || '-'}</div>
184
- </ButtonGroup>
185
-
81
+ <div className={`text-ellipsis break-words`}>Chain:{chain.name}</div>
82
+ <div className={`text-ellipsis break-words`}>address:{address}</div>
186
83
  <div className={`text-ellipsis break-words`}>balance:{balanceQuery.data?.toString()} wei/{balanceEth} eth</div>
187
84
  <div className={`text-ellipsis break-words`}>gas price:{gasPriceQuery.data?.toString()} wei</div>
188
-
85
+ <div className={`flex gap-[20px]`}>
86
+ <input className="border" type={'text'} placeholder={'message'} value={message}
87
+ onChange={(e) => setMessage(e.target.value)}/>
88
+ <button className={`bg-gray-300 p-1 rounded`}
89
+ onClick={onSign}>Sign message
90
+ </button>
91
+ </div>
92
+ <div>
93
+ Signature:{signature}
94
+ </div>
189
95
  <div className="text-bold">
190
96
  Send Transaction
191
97
  </div>
@@ -204,142 +110,21 @@ export default function Wallet() {
204
110
  <input className="border" type={'text'} placeholder={'data'} value={data}
205
111
  onChange={(e) => setToData(e.target.value)}/>
206
112
  </div>
207
- <ButtonGroup>
208
- <Button onClick={onSignTransaction} size={"sm"} disabled={!walletReady}>Sign</Button>
209
- <Button onClick={onSendTransaction} size={"sm"} disabled={!walletReady}>Send</Button>
210
- </ButtonGroup>
211
- <ButtonGroup title={"TxSignature"}>
212
- <div className={`flex-1 flex-wrap break-all`}>{transactionSign || '-'}</div>
213
- </ButtonGroup>
214
- <ButtonGroup title={"TxHash"}>
215
- <div className={`flex-1 flex-wrap break-all`}>{hash || '-'}</div>
216
- </ButtonGroup>
217
- <ERC20/>
218
- </div>
219
- }
220
-
221
- function ERC20() {
222
- const {initChainId, erc20Address, setErc20Address} = useLocalStore()
223
- const [hash, setHash] = useState('')
224
- const [amount, setAmount] = useState('1')
225
- const [to, setTo] = useState('')
226
- const {address, evmAccount, createWalletClient, walletReady} = useWallet()
227
- const [loading,setLoading] = useState(false)
228
- const chain = chainList.find((chain) => chain.id === initChainId)
229
- const publicClient = createPublicClient({
230
- chain: chain,
231
- transport: http() as Transport,
232
- });
233
-
234
- const decimalsQuery = useQuery({
235
- queryKey: ['erc20decimals', erc20Address],
236
- queryFn: async () => {
237
- return await publicClient.readContract({
238
- abi: Erc20Abi,
239
- address: erc20Address as `0x${string}`,
240
- functionName: 'decimals',
241
- args: []
242
- }) as number
243
- },
244
- enabled:!!erc20Address
245
- })
246
-
247
- const symbolQuery = useQuery({
248
- queryKey: ['erc20symbol', erc20Address],
249
- queryFn: async () => {
250
- return await publicClient.readContract({
251
- abi: Erc20Abi,
252
- address: erc20Address as `0x${string}`,
253
- functionName: 'symbol',
254
- args: []
255
- }) as string
256
- },
257
- enabled:!!erc20Address
258
- })
259
-
260
- const balanceQuery = useQuery({
261
- queryKey: ['erc20balance', address],
262
- refetchInterval: 15_000,
263
- queryFn: async () => {
264
- return await publicClient.readContract({
265
- abi:Erc20Abi,
266
- address:erc20Address as `0x${string}`,
267
- functionName:'balanceOf',
268
- args:[address]
269
- }) as bigint
270
- },
271
- enabled:!!erc20Address&&!!address
272
- })
273
-
274
- const balanceUnit = useMemo(()=>{
275
- if(!decimalsQuery.data) return ''
276
- if(!balanceQuery.data) return ''
277
-
278
- return formatUnits(balanceQuery.data,decimalsQuery.data)
279
- },[balanceQuery.data,decimalsQuery.data])
280
-
281
- console.log(balanceQuery,symbolQuery,decimalsQuery)
282
- const onSend = async()=>{
283
- try{
284
- setLoading(true)
285
- if(!walletReady) throw new Error('wallet not ready')
286
- if(!evmAccount) throw new Error('account not ready')
287
- if(!erc20Address) throw new Error('erc20Address not ready')
288
- if(!to) throw new Error('to not ready')
289
- if(!amount) throw new Error('amount not ready')
290
-
291
- const walletClient = createWalletClient({
292
- chain:chain,
293
- transport:http(),
294
- })
295
- if(walletClient){
296
-
297
- const hash = await walletClient?.writeContract({
298
- address:erc20Address as `0x${string}`,
299
- abi:Erc20Abi as any,
300
- functionName:'transfer',
301
- args:[to,parseUnits(amount,decimalsQuery.data||18)],
302
- })
303
- setHash(hash)
304
- }
113
+ <div className={`flex gap-[20px]`}>
114
+ <button className={`bg-gray-300 p-1 rounded`}
115
+ onClick={onSignTransaction}>Sign
116
+ </button>
117
+ <button className={`bg-gray-300 p-1 rounded`}
118
+ onClick={onSendTransaction}>Send
119
+ </button>
120
+ </div>
121
+ <div>
122
+ Sign:{transactionSign}
123
+ </div>
124
+ <div>
125
+ TxHash:{hash}
126
+ </div>
305
127
 
306
128
 
307
- }catch(error:any){
308
- console.error(error)
309
- alert(error.message)
310
- }finally {
311
- setLoading(false)
312
- }
313
- }
314
- return <div>
315
- <ButtonGroup title={"ERC20"}></ButtonGroup>
316
- <ButtonGroup title={"Contract Address"}>
317
- <input className="border px-[8px]" type={'text'} placeholder={'contact'} value={erc20Address}
318
- onChange={(e) => setErc20Address(e.target.value)}/>
319
- </ButtonGroup>
320
- <ButtonGroup title={"Info"}>
321
- <div className={`flex-1 flex-wrap break-all`}>Symbol:{symbolQuery.data}</div>
322
- <div className={`flex-1 flex-wrap break-all`}>Decimals:{decimalsQuery.data}</div>
323
- </ButtonGroup>
324
- <ButtonGroup title={"Balance"}>
325
- <div className={`flex-1 flex-wrap break-all`}>{balanceQuery.data?.toString()}</div>
326
- <div className={`flex-1 flex-wrap break-all`}>{balanceUnit} {symbolQuery.data}</div>
327
- </ButtonGroup>
328
- <ButtonGroup title={"Send"}>
329
- <div className={`flex-1 flex-wrap break-all`}>
330
- To Address:
331
- <input className="border px-[8px]" type={'text'} placeholder={'address'} value={to}
332
- onChange={(e) => setTo(e.target.value)}/>
333
- </div>
334
- <div className={`flex-1 flex-wrap break-all`}>
335
- Amount:
336
- <input className="border px-[8px]" type={'text'} placeholder={'amount'} value={amount}
337
- onChange={(e) => setAmount(e.target.value)}/>
338
- </div>
339
- <Button size={"sm"} loading={loading} onClick={onSend} disabled={!to||!amount}>Send</Button>
340
- </ButtonGroup>
341
- <ButtonGroup title={"Hash"}>
342
- <div className={`flex-1 flex-wrap break-all`}>{hash}</div>
343
- </ButtonGroup>
344
129
  </div>
345
130
  }
@@ -10,7 +10,6 @@
10
10
  "moduleResolution": "node", // 使用 Node.js 风格的模块解析
11
11
  "esModuleInterop": true,
12
12
  "skipLibCheck": true,
13
- "resolveJsonModule": true,
14
13
  "forceConsistentCasingInFileNames": true,
15
14
  "baseUrl": "./",
16
15
  "paths": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matchain/matchid-sdk-react",
3
- "version": "0.1.42-alpha.16",
3
+ "version": "0.1.42-alpha.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -28,10 +28,6 @@
28
28
  "import": "./dist/assets/icon/index.mjs",
29
29
  "require": "./dist/assets/icon/index.js"
30
30
  },
31
- "./types": {
32
- "import": "./dist/types/index.mjs",
33
- "require": "./dist/types/index.js"
34
- },
35
31
  "./index.css": "./dist/index.css"
36
32
  },
37
33
  "scripts": {
@@ -85,7 +81,6 @@
85
81
  "chokidar": "^4.0.3",
86
82
  "npm-run-all": "^4.1.5",
87
83
  "tsup": "^8.3.5",
88
- "typescript": "^5.6.3",
89
- "url-loader": "^4.1.1"
84
+ "typescript": "^5.6.3"
90
85
  }
91
86
  }
@@ -1,29 +0,0 @@
1
- import {
2
- __export
3
- } from "./chunk-J5LGTIGS.mjs";
4
-
5
- // src/types/index.ts
6
- var types_exports = {};
7
- __export(types_exports, {
8
- ChainType: () => ChainType,
9
- RecoveryType: () => RecoveryType
10
- });
11
-
12
- // src/types/mpc.ts
13
- var ChainType = /* @__PURE__ */ ((ChainType2) => {
14
- ChainType2["Ethereum"] = "ethereum";
15
- ChainType2["Solana"] = "solana";
16
- return ChainType2;
17
- })(ChainType || {});
18
- var RecoveryType = /* @__PURE__ */ ((RecoveryType2) => {
19
- RecoveryType2["Base"] = "base_generated_recovery_key";
20
- RecoveryType2["UserPasscode"] = "user_passcode_recovery_key";
21
- return RecoveryType2;
22
- })(RecoveryType || {});
23
-
24
- export {
25
- ChainType,
26
- RecoveryType,
27
- types_exports
28
- };
29
- //# sourceMappingURL=chunk-SQIJR7RA.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/index.ts","../src/types/mpc.ts"],"sourcesContent":["export * from \"./mpc\"\nexport * from \"./types\"","export interface AuthParams {\n AppId: string;\n AppClientId: string;\n UserId: string;\n AccessToken: string;\n Address?: string;\n}\n\nexport interface EmbeddedWalletsParams {\n Url: string;\n}\nexport enum ChainType {\n Ethereum = \"ethereum\",\n Solana = \"solana\"\n}\nexport enum RecoveryType {\n Base = \"base_generated_recovery_key\",\n UserPasscode = \"user_passcode_recovery_key\"\n}\n// export type ChainType = \"ethereum\" | \"solana\";\n// export type RecoveryType = \"base_generated_recovery_key\" | \"user_passcode_recovery_key\""],"mappings":";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAK,YAAL,kBAAKA,eAAL;AACH,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,YAAS;AAFD,SAAAA;AAAA,GAAA;AAIL,IAAK,eAAL,kBAAKC,kBAAL;AACH,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,kBAAe;AAFP,SAAAA;AAAA,GAAA;","names":["ChainType","RecoveryType"]}