@matchain/matchid-sdk-react 0.1.7
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/index.css +461 -0
- package/dist/index.d.mts +211 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.js +1990 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1956 -0
- package/dist/index.mjs.map +1 -0
- package/example/index.html +13 -0
- package/example/package-lock.json +2965 -0
- package/example/package.json +34 -0
- package/example/postcss.config.js +6 -0
- package/example/src/App.tsx +61 -0
- package/example/src/app.css +3 -0
- package/example/src/config/contract.ts +154 -0
- package/example/src/main.tsx +5 -0
- package/example/src/pages/Home.tsx +36 -0
- package/example/src/pages/Login.tsx +165 -0
- package/example/tailwind.config.js +11 -0
- package/example/tsconfig.json +17 -0
- package/example/vite.config.ts +13 -0
- package/example/yarn.lock +1373 -0
- package/package.json +58 -0
- package/readme.md +5 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import React$1, { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import * as viem from 'viem';
|
|
4
|
+
import { SignableMessage, Hex, TransactionSerializable } from 'viem';
|
|
5
|
+
|
|
6
|
+
type LoginMethodType = 'wallet' | 'email' | 'google' | 'X' | 'telegram'
|
|
7
|
+
type IEnvName = 'main' | 'dev' | 'test'
|
|
8
|
+
type IMatchEvents = {
|
|
9
|
+
onLogin?: (data: {
|
|
10
|
+
mid?: string;
|
|
11
|
+
token: string;
|
|
12
|
+
did: string
|
|
13
|
+
}) => void
|
|
14
|
+
onLogout?: () => void,
|
|
15
|
+
onBind?: (data: {
|
|
16
|
+
type: string
|
|
17
|
+
}) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type OverviewInfo = {
|
|
21
|
+
score: number,
|
|
22
|
+
total_assets: number,
|
|
23
|
+
wallets: number,
|
|
24
|
+
followers: number,
|
|
25
|
+
sbt: number,
|
|
26
|
+
is_kyc: boolean,
|
|
27
|
+
is_poh: boolean,
|
|
28
|
+
mid: string
|
|
29
|
+
user_identity: string
|
|
30
|
+
identities: { [key: string]: string }
|
|
31
|
+
did: string
|
|
32
|
+
address: string
|
|
33
|
+
username?:string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type ModalProps = PropsWithChildren & {
|
|
37
|
+
isOpen: boolean,
|
|
38
|
+
width?: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type ModalWithHeaderProps = ModalProps & {
|
|
42
|
+
onBack?: () => void,
|
|
43
|
+
onClose?: () => void,
|
|
44
|
+
title?: string
|
|
45
|
+
showClose?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type InputProps = {
|
|
49
|
+
placeholder: string,
|
|
50
|
+
value: string,
|
|
51
|
+
onChange: (e?: any) => void,
|
|
52
|
+
disabled?: boolean,
|
|
53
|
+
readonly?: boolean
|
|
54
|
+
type?: string
|
|
55
|
+
maxLength?: number
|
|
56
|
+
after?: React.ReactNode
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type LoginBoxProps = {
|
|
60
|
+
methods?: LoginMethodType[],
|
|
61
|
+
inModal?: boolean
|
|
62
|
+
}
|
|
63
|
+
type LoginPanelProps = {
|
|
64
|
+
header?: React.ReactNode
|
|
65
|
+
onClose?: () => void
|
|
66
|
+
} & LoginBoxProps
|
|
67
|
+
type LoginModalProps = LoginPanelProps & ModalProps
|
|
68
|
+
type EmailModalProps = ModalProps & {
|
|
69
|
+
onClose?: () => void,
|
|
70
|
+
onBack?: () => void,
|
|
71
|
+
onLogin?: () => void
|
|
72
|
+
}
|
|
73
|
+
type ButtonProps = {
|
|
74
|
+
size?: 'sm' | 'df' | 'lg',
|
|
75
|
+
type?: "button" | "submit" | "reset",
|
|
76
|
+
rounded?: boolean,
|
|
77
|
+
block?: boolean,
|
|
78
|
+
disabled?: boolean,
|
|
79
|
+
loading?: boolean,
|
|
80
|
+
children?: React.ReactNode,
|
|
81
|
+
onClick?: () => void,
|
|
82
|
+
highlight?: boolean,
|
|
83
|
+
style?: CSSProperties
|
|
84
|
+
className?: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type MatchContextType = {
|
|
88
|
+
env: IEnvName;
|
|
89
|
+
appid: string;
|
|
90
|
+
endpoints: {
|
|
91
|
+
login: string;
|
|
92
|
+
back: string;
|
|
93
|
+
};
|
|
94
|
+
events?: IMatchEvents;
|
|
95
|
+
login: (data: {
|
|
96
|
+
mid: string;
|
|
97
|
+
token: string;
|
|
98
|
+
}) => Promise<void>;
|
|
99
|
+
theme: "light" | "dark";
|
|
100
|
+
};
|
|
101
|
+
declare const MatchProvider: React$1.FC<{
|
|
102
|
+
children: ReactNode;
|
|
103
|
+
appid: string;
|
|
104
|
+
env?: IEnvName;
|
|
105
|
+
events?: IMatchEvents;
|
|
106
|
+
theme?: "light" | "dark";
|
|
107
|
+
}>;
|
|
108
|
+
declare const useMatch: () => MatchContextType;
|
|
109
|
+
|
|
110
|
+
declare function EmailModal({ isOpen, width, onClose, onBack, onLogin }: EmailModalProps): react_jsx_runtime.JSX.Element;
|
|
111
|
+
|
|
112
|
+
declare function Field({ label, children, error }: {
|
|
113
|
+
label: ReactNode;
|
|
114
|
+
error?: ReactNode;
|
|
115
|
+
} & PropsWithChildren): react_jsx_runtime.JSX.Element;
|
|
116
|
+
|
|
117
|
+
declare function Input({ onChange, type, after, ...props }: InputProps): react_jsx_runtime.JSX.Element;
|
|
118
|
+
|
|
119
|
+
declare function Button({ size, disabled, loading, children, onClick, highlight, block, type, rounded, className, style }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
120
|
+
|
|
121
|
+
declare function LoginBox({ methods, inModal }: LoginBoxProps): react_jsx_runtime.JSX.Element;
|
|
122
|
+
|
|
123
|
+
declare function Modal({ children, isOpen, width }: ModalProps): react_jsx_runtime.JSX.Element;
|
|
124
|
+
declare function ModalWithHeader({ children, onBack, onClose, title, showClose, ...props }: ModalWithHeaderProps): react_jsx_runtime.JSX.Element;
|
|
125
|
+
|
|
126
|
+
declare function LoginButton({ loginRender, methods, onLoginClick, ...props }: Omit<ButtonProps, 'onClick' | 'highlight'> & {
|
|
127
|
+
loginRender?: () => JSX.Element;
|
|
128
|
+
methods?: LoginMethodType[];
|
|
129
|
+
onLoginClick?: () => void;
|
|
130
|
+
}): react_jsx_runtime.JSX.Element;
|
|
131
|
+
|
|
132
|
+
declare function LoginPanel({ header, onClose, ...props }: LoginPanelProps): react_jsx_runtime.JSX.Element;
|
|
133
|
+
|
|
134
|
+
declare function LoginModal({ isOpen, width, ...props }: LoginModalProps): react_jsx_runtime.JSX.Element;
|
|
135
|
+
|
|
136
|
+
declare function UsernameModal({ title, isOpen, onSuccess, ...props }: ModalWithHeaderProps & {
|
|
137
|
+
onSuccess?: () => void;
|
|
138
|
+
}): react_jsx_runtime.JSX.Element;
|
|
139
|
+
|
|
140
|
+
declare function PasswordModal({ title, isOpen, onSuccess, ...props }: ModalWithHeaderProps & {
|
|
141
|
+
onSuccess?: () => void;
|
|
142
|
+
}): react_jsx_runtime.JSX.Element;
|
|
143
|
+
|
|
144
|
+
declare const index$1_Button: typeof Button;
|
|
145
|
+
declare const index$1_EmailModal: typeof EmailModal;
|
|
146
|
+
declare const index$1_Field: typeof Field;
|
|
147
|
+
declare const index$1_Input: typeof Input;
|
|
148
|
+
declare const index$1_LoginBox: typeof LoginBox;
|
|
149
|
+
declare const index$1_LoginButton: typeof LoginButton;
|
|
150
|
+
declare const index$1_LoginModal: typeof LoginModal;
|
|
151
|
+
declare const index$1_LoginPanel: typeof LoginPanel;
|
|
152
|
+
declare const index$1_Modal: typeof Modal;
|
|
153
|
+
declare const index$1_ModalWithHeader: typeof ModalWithHeader;
|
|
154
|
+
declare const index$1_PasswordModal: typeof PasswordModal;
|
|
155
|
+
declare const index$1_UsernameModal: typeof UsernameModal;
|
|
156
|
+
declare namespace index$1 {
|
|
157
|
+
export { index$1_Button as Button, index$1_EmailModal as EmailModal, index$1_Field as Field, index$1_Input as Input, index$1_LoginBox as LoginBox, index$1_LoginButton as LoginButton, index$1_LoginModal as LoginModal, index$1_LoginPanel as LoginPanel, index$1_Modal as Modal, index$1_ModalWithHeader as ModalWithHeader, index$1_PasswordModal as PasswordModal, index$1_UsernameModal as UsernameModal };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare function useUserInfo(): {
|
|
161
|
+
loginByTelegram: () => void;
|
|
162
|
+
loginByTwitter: () => void;
|
|
163
|
+
loginByGoogle: () => void;
|
|
164
|
+
loginByWallet: () => void;
|
|
165
|
+
loginByEmail: ({ email, code }: {
|
|
166
|
+
email: string;
|
|
167
|
+
code: string;
|
|
168
|
+
}) => Promise<boolean>;
|
|
169
|
+
token: string;
|
|
170
|
+
mid: string;
|
|
171
|
+
did: string;
|
|
172
|
+
address: string;
|
|
173
|
+
isLogin: boolean;
|
|
174
|
+
logout: () => Promise<void>;
|
|
175
|
+
getLoginEmailCode: (email: string) => Promise<string>;
|
|
176
|
+
refreshOverview: () => Promise<void>;
|
|
177
|
+
overview: OverviewInfo | null;
|
|
178
|
+
bindWallet: () => Promise<void>;
|
|
179
|
+
bindTelegram: () => Promise<void>;
|
|
180
|
+
username: string;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
declare function useMatchEvents(handlers: IMatchEvents): void;
|
|
184
|
+
|
|
185
|
+
type ChainType = "ethereum" | "solana";
|
|
186
|
+
type RecoveryType = "base_generated_recovery_key" | "user_passcode_recovery_key"
|
|
187
|
+
|
|
188
|
+
interface UseWalletReturnType {
|
|
189
|
+
initWallet: (params: {
|
|
190
|
+
address: string;
|
|
191
|
+
did: string;
|
|
192
|
+
}) => Promise<void>;
|
|
193
|
+
generateWallet: (params: {
|
|
194
|
+
did: string;
|
|
195
|
+
userPasscode: string;
|
|
196
|
+
}) => Promise<string>;
|
|
197
|
+
isRecovered: () => Promise<boolean>;
|
|
198
|
+
recoveryWallet: (chainType: ChainType | undefined, recoveryType: RecoveryType, userPasscode?: string) => Promise<void>;
|
|
199
|
+
signMessage: (message: SignableMessage, type?: ChainType) => Promise<Hex>;
|
|
200
|
+
signTransaction: (transaction: TransactionSerializable, type?: ChainType) => Promise<`0x02${string}` | `0x01${string}` | `0x03${string}` | `0x04${string}` | viem.TransactionSerializedLegacy>;
|
|
201
|
+
}
|
|
202
|
+
declare function useWallet(): UseWalletReturnType;
|
|
203
|
+
|
|
204
|
+
declare const index_useMatchEvents: typeof useMatchEvents;
|
|
205
|
+
declare const index_useUserInfo: typeof useUserInfo;
|
|
206
|
+
declare const index_useWallet: typeof useWallet;
|
|
207
|
+
declare namespace index {
|
|
208
|
+
export { index_useMatchEvents as useMatchEvents, index_useUserInfo as useUserInfo, index_useWallet as useWallet };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { index$1 as Components, index as Hooks, MatchProvider, useMatch };
|