@talken/talkenkit 2.3.5 → 2.3.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/components/ChainIndicator/ChainIndicator.css.d.ts +4 -0
- package/dist/components/ChainIndicator/ChainIndicator.d.ts +53 -0
- package/dist/components/ChainIndicator/index.d.ts +2 -0
- package/dist/components/ChainSelector/ChainSelector.css.d.ts +5 -0
- package/dist/components/ChainSelector/ChainSelector.d.ts +38 -0
- package/dist/components/ChainSelector/index.d.ts +2 -0
- package/dist/components/ConnectButton/ConnectButtonRenderer.d.ts +9 -0
- package/dist/components/ConnectOptions/DesktopOptions.d.ts +5 -1
- package/dist/components/ConnectOptions/MultiChainConnectOptions.d.ts +31 -0
- package/dist/components/ConnectOptions/index.d.ts +3 -0
- package/dist/components/ModalSelection/ModalSelection.d.ts +2 -1
- package/dist/components/ProfileDetails/ProfileDetails.d.ts +1 -2
- package/dist/components/RainbowKitProvider/RainbowKitProvider.d.ts +8 -1
- package/dist/components/SolanaWalletList/SolanaWalletList.css.d.ts +7 -0
- package/dist/components/SolanaWalletList/SolanaWalletList.d.ts +32 -0
- package/dist/components/SolanaWalletList/index.d.ts +2 -0
- package/dist/contexts/MultiChainContext.d.ts +68 -0
- package/dist/contexts/index.d.ts +7 -0
- package/dist/index.css +105 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1445 -899
- package/dist/solana/SolanaWalletProvider.d.ts +38 -0
- package/dist/solana/config.d.ts +57 -0
- package/dist/solana/index.d.ts +11 -0
- package/dist/solana/utils/detection.d.ts +27 -0
- package/dist/solana/wallets/backpackWallet.d.ts +19 -0
- package/dist/solana/wallets/index.d.ts +8 -0
- package/dist/solana/wallets/phantomSolanaWallet.d.ts +17 -0
- package/dist/solana/wallets/solflareWallet.d.ts +17 -0
- package/dist/types/solana.d.ts +97 -0
- package/dist/wallets/recentSolanaWalletIds.d.ts +16 -0
- package/dist/wallets/walletConnectors/abcWallet/abcApi.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWallet.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/index.js +4 -4
- package/dist/wallets/walletConnectors/chunk-3SVPZCA6.js +71 -0
- package/dist/wallets/walletConnectors/chunk-5QEUEPNY.js +94 -0
- package/dist/wallets/walletConnectors/chunk-B6JLYR3I.js +66 -0
- package/dist/wallets/walletConnectors/{chunk-6JKWIEGA.js → chunk-BHMMHU7Y.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-HKWBR5B7.js +102 -0
- package/dist/wallets/walletConnectors/chunk-K4APJ4PE.js +96 -0
- package/dist/wallets/walletConnectors/chunk-LJ2B47VF.js +108 -0
- package/dist/wallets/walletConnectors/chunk-LXINMUQC.js +186 -0
- package/dist/wallets/walletConnectors/chunk-MORUEOYX.js +76 -0
- package/dist/wallets/walletConnectors/chunk-MQTXA63X.js +27 -0
- package/dist/wallets/walletConnectors/{chunk-G2IHR6PW.js → chunk-NLKL4KD2.js} +11 -11
- package/dist/wallets/walletConnectors/{chunk-KOT7JYJR.js → chunk-OEB7MRS5.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-RWIZ25FJ.js → chunk-P2E4LSYH.js} +17 -23
- package/dist/wallets/walletConnectors/chunk-PMZJGS7X.js +73 -0
- package/dist/wallets/walletConnectors/{chunk-BRM4ZVXZ.js → chunk-RSZS2RMC.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-WZZVA3LW.js +101 -0
- package/dist/wallets/walletConnectors/chunk-XEIKWKH7.js +63 -0
- package/dist/wallets/walletConnectors/chunk-XOQNQKZE.js +98 -0
- package/dist/wallets/walletConnectors/chunk-ZAGAF6PO.js +63 -0
- package/dist/wallets/walletConnectors/chunk-ZJ6OFFD5.js +95 -0
- package/dist/wallets/walletConnectors/index.js +24 -24
- package/package.json +17 -11
- package/LICENSE +0 -9
- package/dist/wallets/walletConnectors/chunk-2J66VMY5.js +0 -152
- package/dist/wallets/walletConnectors/chunk-2ZPGPZCP.js +0 -228
- package/dist/wallets/walletConnectors/chunk-3DPCIDW6.js +0 -1730
- package/dist/wallets/walletConnectors/chunk-4HKJ53H3.js +0 -1742
- package/dist/wallets/walletConnectors/chunk-5EARL7FN.js +0 -39
- package/dist/wallets/walletConnectors/chunk-7SXCH5TL.js +0 -1752
- package/dist/wallets/walletConnectors/chunk-7UZBDZZZ.js +0 -599
- package/dist/wallets/walletConnectors/chunk-BUDWZAL7.js +0 -44
- package/dist/wallets/walletConnectors/chunk-CSWWNAYR.js +0 -44
- package/dist/wallets/walletConnectors/chunk-E4N7SPPU.js +0 -39
- package/dist/wallets/walletConnectors/chunk-ENU7XLF5.js +0 -44
- package/dist/wallets/walletConnectors/chunk-ESRU5KCF.js +0 -151
- package/dist/wallets/walletConnectors/chunk-FF7ZIXKD.js +0 -39
- package/dist/wallets/walletConnectors/chunk-FJCL2YPU.js +0 -1737
- package/dist/wallets/walletConnectors/chunk-FSU3WBH3.js +0 -63
- package/dist/wallets/walletConnectors/chunk-HD6YCICR.js +0 -228
- package/dist/wallets/walletConnectors/chunk-HDYBRMYW.js +0 -194
- package/dist/wallets/walletConnectors/chunk-HIZCIW5L.js +0 -228
- package/dist/wallets/walletConnectors/chunk-JRNBDHFL.js +0 -44
- package/dist/wallets/walletConnectors/chunk-KIQDE4N6.js +0 -39
- package/dist/wallets/walletConnectors/chunk-KZOSE2PI.js +0 -228
- package/dist/wallets/walletConnectors/chunk-LNZJLKFB.js +0 -39
- package/dist/wallets/walletConnectors/chunk-LV765WZL.js +0 -1748
- package/dist/wallets/walletConnectors/chunk-MSI2BPP5.js +0 -1722
- package/dist/wallets/walletConnectors/chunk-MX2IY5CD.js +0 -44
- package/dist/wallets/walletConnectors/chunk-NLX2EV7O.js +0 -44
- package/dist/wallets/walletConnectors/chunk-NVAZ3B3V.js +0 -228
- package/dist/wallets/walletConnectors/chunk-OEWU3ZMN.js +0 -39
- package/dist/wallets/walletConnectors/chunk-P2MTINFI.js +0 -280
- package/dist/wallets/walletConnectors/chunk-PNMSIVVT.js +0 -44
- package/dist/wallets/walletConnectors/chunk-PZNYT2HC.js +0 -1722
- package/dist/wallets/walletConnectors/chunk-QPAE4SDS.js +0 -39
- package/dist/wallets/walletConnectors/chunk-QZRNNI3E.js +0 -39
- package/dist/wallets/walletConnectors/chunk-R4UYVU5X.js +0 -1721
- package/dist/wallets/walletConnectors/chunk-RLBGBBIO.js +0 -309
- package/dist/wallets/walletConnectors/chunk-TUUNSVKZ.js +0 -345
- package/dist/wallets/walletConnectors/chunk-U2CUEL35.js +0 -240
- package/dist/wallets/walletConnectors/chunk-V6NRLREB.js +0 -44
- package/dist/wallets/walletConnectors/chunk-VM7AEC7H.js +0 -39
- package/dist/wallets/walletConnectors/chunk-W2VDZD74.js +0 -478
- package/dist/wallets/walletConnectors/chunk-WAO3KL5U.js +0 -285
- package/dist/wallets/walletConnectors/chunk-WPHTIILX.js +0 -228
- package/dist/wallets/walletConnectors/chunk-WSCJY2QD.js +0 -228
- package/dist/wallets/walletConnectors/chunk-X3JQB5QL.js +0 -44
- package/dist/wallets/walletConnectors/chunk-X4CDP7L7.js +0 -228
- package/dist/wallets/walletConnectors/chunk-XETOVXYM.js +0 -228
- package/dist/wallets/walletConnectors/chunk-XYPR4BAF.js +0 -436
- package/dist/wallets/walletConnectors/chunk-Z2ZRPTPX.js +0 -1726
- package/dist/wallets/walletConnectors/{chunk-VCBVYFLJ.js → chunk-6TLWAEJV.js} +7 -7
- package/dist/wallets/walletConnectors/{chunk-47TQ23J4.js → chunk-74ALNZG4.js} +8 -8
- package/dist/wallets/walletConnectors/{chunk-66SCJ77O.js → chunk-CM5OGUJV.js} +6 -6
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
BaseApiClient
|
|
4
|
-
} from "./chunk-WAO3KL5U.js";
|
|
5
|
-
import {
|
|
6
|
-
createAbcError
|
|
7
|
-
} from "./chunk-W2VDZD74.js";
|
|
8
|
-
import {
|
|
9
|
-
ABC_AUDIENCE,
|
|
10
|
-
ABC_ENDPOINTS
|
|
11
|
-
} from "./chunk-VETRBBA2.js";
|
|
12
|
-
|
|
13
|
-
// src/wallets/walletConnectors/abcWallet/api/AuthApi.ts
|
|
14
|
-
var AuthApi = class extends BaseApiClient {
|
|
15
|
-
/**
|
|
16
|
-
* Login with email and password
|
|
17
|
-
*/
|
|
18
|
-
async loginWithEmail(email, password) {
|
|
19
|
-
const response = await this.request(
|
|
20
|
-
ABC_ENDPOINTS.SNS_LOGIN,
|
|
21
|
-
{
|
|
22
|
-
method: "POST",
|
|
23
|
-
body: {
|
|
24
|
-
email,
|
|
25
|
-
token: password,
|
|
26
|
-
service: "email",
|
|
27
|
-
audience: ABC_AUDIENCE
|
|
28
|
-
},
|
|
29
|
-
skipAuth: true
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
if (response.status === "success" && response.data) {
|
|
33
|
-
this.saveTokens(
|
|
34
|
-
response.data.accessToken,
|
|
35
|
-
response.data.refreshToken,
|
|
36
|
-
response.data.expiresIn
|
|
37
|
-
);
|
|
38
|
-
return response.data;
|
|
39
|
-
}
|
|
40
|
-
throw createAbcError(
|
|
41
|
-
"INVALID_CREDENTIALS" /* INVALID_CREDENTIALS */,
|
|
42
|
-
"Email login failed",
|
|
43
|
-
response
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Login with email and OTP (for PIN recovery)
|
|
48
|
-
*/
|
|
49
|
-
async loginWithOtp(email, otpCode) {
|
|
50
|
-
const response = await this.request(
|
|
51
|
-
ABC_ENDPOINTS.SNS_LOGIN,
|
|
52
|
-
{
|
|
53
|
-
method: "POST",
|
|
54
|
-
body: {
|
|
55
|
-
email,
|
|
56
|
-
token: otpCode,
|
|
57
|
-
service: "email",
|
|
58
|
-
audience: ABC_AUDIENCE
|
|
59
|
-
},
|
|
60
|
-
skipAuth: true
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
if (response.status === "success" && response.data) {
|
|
64
|
-
this.saveTokens(
|
|
65
|
-
response.data.accessToken,
|
|
66
|
-
response.data.refreshToken,
|
|
67
|
-
response.data.expiresIn
|
|
68
|
-
);
|
|
69
|
-
return response.data;
|
|
70
|
-
}
|
|
71
|
-
throw createAbcError(
|
|
72
|
-
"INVALID_CREDENTIALS" /* INVALID_CREDENTIALS */,
|
|
73
|
-
"OTP login failed",
|
|
74
|
-
response
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Login with social provider
|
|
79
|
-
*/
|
|
80
|
-
async loginWithSocial(provider, token, email) {
|
|
81
|
-
const response = await this.request(
|
|
82
|
-
ABC_ENDPOINTS.SNS_LOGIN,
|
|
83
|
-
{
|
|
84
|
-
method: "POST",
|
|
85
|
-
body: {
|
|
86
|
-
token,
|
|
87
|
-
service: provider,
|
|
88
|
-
audience: ABC_AUDIENCE,
|
|
89
|
-
email
|
|
90
|
-
},
|
|
91
|
-
skipAuth: true
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
if (response.status === "success" && response.data) {
|
|
95
|
-
this.saveTokens(
|
|
96
|
-
response.data.accessToken,
|
|
97
|
-
response.data.refreshToken,
|
|
98
|
-
response.data.expiresIn
|
|
99
|
-
);
|
|
100
|
-
return response.data;
|
|
101
|
-
}
|
|
102
|
-
throw createAbcError(
|
|
103
|
-
"INVALID_CREDENTIALS" /* INVALID_CREDENTIALS */,
|
|
104
|
-
"Social login failed",
|
|
105
|
-
response
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Request OTP code for email
|
|
110
|
-
*/
|
|
111
|
-
async requestOtpCode(email) {
|
|
112
|
-
const response = await this.request(
|
|
113
|
-
ABC_ENDPOINTS.SEND_OTP,
|
|
114
|
-
{
|
|
115
|
-
method: "POST",
|
|
116
|
-
body: { email },
|
|
117
|
-
skipAuth: true
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
if (response.status === "success" && response.data) {
|
|
121
|
-
return response.data;
|
|
122
|
-
}
|
|
123
|
-
throw createAbcError(
|
|
124
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
125
|
-
"Failed to request OTP",
|
|
126
|
-
response
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Verify OTP code
|
|
131
|
-
*/
|
|
132
|
-
async verifyOtpCode(email, code) {
|
|
133
|
-
const response = await this.request(ABC_ENDPOINTS.VERIFY_OTP, {
|
|
134
|
-
method: "POST",
|
|
135
|
-
body: { email, code },
|
|
136
|
-
skipAuth: true
|
|
137
|
-
});
|
|
138
|
-
return response.status === "success";
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Check if email already exists
|
|
142
|
-
*/
|
|
143
|
-
async emailCheck(_email) {
|
|
144
|
-
const _talkenApiUrl = process.env.NEXT_PUBLIC_API_SERVER || "https://dev.walletapi.talken.io";
|
|
145
|
-
const url = `${_talkenApiUrl}/abc/emailCheck?email=${encodeURIComponent(_email)}`;
|
|
146
|
-
try {
|
|
147
|
-
const response = await fetch(url, {
|
|
148
|
-
method: "GET",
|
|
149
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
150
|
-
});
|
|
151
|
-
const text = await response.text();
|
|
152
|
-
const data = text ? JSON.parse(text) : { status: "success" };
|
|
153
|
-
if (!response.ok) {
|
|
154
|
-
throw createAbcError(
|
|
155
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
156
|
-
"Email check failed",
|
|
157
|
-
data
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
return data;
|
|
161
|
-
} catch (error) {
|
|
162
|
-
throw createAbcError(
|
|
163
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
164
|
-
"Email check failed",
|
|
165
|
-
error
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Send OTP code to email for signup
|
|
171
|
-
*/
|
|
172
|
-
async sendOtpCode(_email) {
|
|
173
|
-
const endpoint = "/member/mail-service/${encodeURIComponent(email)}/sendcode";
|
|
174
|
-
const response = await this.request(endpoint, {
|
|
175
|
-
method: "GET",
|
|
176
|
-
skipAuth: true
|
|
177
|
-
});
|
|
178
|
-
if (response.status === "success") {
|
|
179
|
-
return response;
|
|
180
|
-
}
|
|
181
|
-
throw createAbcError(
|
|
182
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
183
|
-
"Failed to send OTP code",
|
|
184
|
-
response
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Verify OTP code for signup
|
|
189
|
-
*/
|
|
190
|
-
async verifyOtpCodeSignup(email, code) {
|
|
191
|
-
const endpoint = "/member/mail-service/${encodeURIComponent(email)}/verifycode";
|
|
192
|
-
const requestBody = {
|
|
193
|
-
email,
|
|
194
|
-
code,
|
|
195
|
-
serviceid: ABC_AUDIENCE
|
|
196
|
-
};
|
|
197
|
-
const response = await this.request(endpoint, {
|
|
198
|
-
method: "POST",
|
|
199
|
-
body: requestBody,
|
|
200
|
-
skipAuth: true
|
|
201
|
-
});
|
|
202
|
-
const isSuccess = response.status === "success" || response.status === 200 || response.message === "success";
|
|
203
|
-
if (isSuccess) {
|
|
204
|
-
return response;
|
|
205
|
-
}
|
|
206
|
-
throw createAbcError(
|
|
207
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
208
|
-
"Invalid or expired OTP code",
|
|
209
|
-
response
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Register new user
|
|
214
|
-
*/
|
|
215
|
-
async registerUser(params) {
|
|
216
|
-
const _talkenApiUrl = process.env.NEXT_PUBLIC_API_SERVER || "https://dev.walletapi.talken.io";
|
|
217
|
-
const url = "${talkenApiUrl}/abc/adduser";
|
|
218
|
-
try {
|
|
219
|
-
const response = await fetch(url, {
|
|
220
|
-
method: "POST",
|
|
221
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
222
|
-
credentials: "include",
|
|
223
|
-
body: new URLSearchParams(params).toString()
|
|
224
|
-
});
|
|
225
|
-
const text = await response.text();
|
|
226
|
-
const data = text ? JSON.parse(text) : { status: "success" };
|
|
227
|
-
if (!response.ok) {
|
|
228
|
-
throw createAbcError(
|
|
229
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
230
|
-
"User registration failed",
|
|
231
|
-
data
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
return data;
|
|
235
|
-
} catch (error) {
|
|
236
|
-
throw createAbcError(
|
|
237
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
238
|
-
"User registration failed",
|
|
239
|
-
error
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Register new SNS user (email-based registration with OTP)
|
|
245
|
-
*/
|
|
246
|
-
async registerSnsUser(params) {
|
|
247
|
-
const _talkenApiUrl = process.env.NEXT_PUBLIC_API_SERVER || "https://dev.walletapi.talken.io";
|
|
248
|
-
const url = "${talkenApiUrl}/abc/snsAdduser";
|
|
249
|
-
try {
|
|
250
|
-
const response = await fetch(url, {
|
|
251
|
-
method: "POST",
|
|
252
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
253
|
-
credentials: "include",
|
|
254
|
-
body: new URLSearchParams(params).toString()
|
|
255
|
-
});
|
|
256
|
-
const text = await response.text();
|
|
257
|
-
const data = text ? JSON.parse(text) : { status: "success" };
|
|
258
|
-
if (!response.ok) {
|
|
259
|
-
throw createAbcError(
|
|
260
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
261
|
-
"SNS user registration failed",
|
|
262
|
-
data
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
return data;
|
|
266
|
-
} catch (error) {
|
|
267
|
-
throw createAbcError(
|
|
268
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
269
|
-
"SNS user registration failed",
|
|
270
|
-
error
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Reset/Set password for existing user
|
|
276
|
-
*/
|
|
277
|
-
async resetPassword(params) {
|
|
278
|
-
const _talkenApiUrl = process.env.NEXT_PUBLIC_API_SERVER || "https://dev.walletapi.talken.io";
|
|
279
|
-
const url = "${talkenApiUrl}/abc/initpassword";
|
|
280
|
-
try {
|
|
281
|
-
const response = await fetch(url, {
|
|
282
|
-
method: "POST",
|
|
283
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
284
|
-
credentials: "include",
|
|
285
|
-
body: new URLSearchParams(params).toString()
|
|
286
|
-
});
|
|
287
|
-
const text = await response.text();
|
|
288
|
-
const data = text ? JSON.parse(text) : { status: "success" };
|
|
289
|
-
if (!response.ok) {
|
|
290
|
-
throw createAbcError(
|
|
291
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
292
|
-
"Password reset failed",
|
|
293
|
-
data
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
return data;
|
|
297
|
-
} catch (error) {
|
|
298
|
-
throw createAbcError(
|
|
299
|
-
"UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
300
|
-
"Password reset failed",
|
|
301
|
-
error
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
export {
|
|
308
|
-
AuthApi
|
|
309
|
-
};
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
BaseApiClient
|
|
4
|
-
} from "./chunk-WAO3KL5U.js";
|
|
5
|
-
import {
|
|
6
|
-
createAbcError,
|
|
7
|
-
loadFromStorage
|
|
8
|
-
} from "./chunk-W2VDZD74.js";
|
|
9
|
-
import {
|
|
10
|
-
ABC_ENDPOINTS
|
|
11
|
-
} from "./chunk-VETRBBA2.js";
|
|
12
|
-
|
|
13
|
-
// src/wallets/walletConnectors/abcWallet/api/SigningApi.ts
|
|
14
|
-
import { getAddress } from "viem";
|
|
15
|
-
var SigningApi = class extends BaseApiClient {
|
|
16
|
-
/**
|
|
17
|
-
* Sign EVM transaction (EIP-1559)
|
|
18
|
-
*/
|
|
19
|
-
async signTransaction(params) {
|
|
20
|
-
this.loadTokens();
|
|
21
|
-
const wallet = loadFromStorage("wallet" /* WALLET */);
|
|
22
|
-
if (!wallet) {
|
|
23
|
-
throw createAbcError(
|
|
24
|
-
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
25
|
-
"Wallet information not found in storage"
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
const encryptedDevicePassword = await this.secure.getEncryptPlain(
|
|
29
|
-
wallet.encryptDevicePassword
|
|
30
|
-
);
|
|
31
|
-
const encryptedPvencstr = await this.secure.getEncryptPlain(
|
|
32
|
-
wallet.pvencstr
|
|
33
|
-
);
|
|
34
|
-
const encryptedWid = await this.secure.getEncryptPlain(wallet.wid);
|
|
35
|
-
const secureChannelId = await this.secure.getSecureChannelId();
|
|
36
|
-
const network = this.getNetworkName(params.chainId);
|
|
37
|
-
const tx = params.transaction;
|
|
38
|
-
const _isContractDeployment = !params.transaction.to || params.transaction.to === "0x" || params.transaction.to === "0x0";
|
|
39
|
-
const bodyData = {
|
|
40
|
-
network,
|
|
41
|
-
encryptDevicePassword: encryptedDevicePassword,
|
|
42
|
-
pvencstr: encryptedPvencstr,
|
|
43
|
-
uid: wallet.uid,
|
|
44
|
-
wid: encryptedWid,
|
|
45
|
-
sid: getAddress(wallet.address),
|
|
46
|
-
to: tx.to === "0x" ? "0x" : getAddress(tx.to),
|
|
47
|
-
type: "EIP1559",
|
|
48
|
-
ourpubkey: "",
|
|
49
|
-
ucpubkey: ""
|
|
50
|
-
};
|
|
51
|
-
bodyData.from = getAddress(tx.from || wallet.address);
|
|
52
|
-
if (tx.value) {
|
|
53
|
-
let hexValue = tx.value.startsWith("0x") ? tx.value.slice(2) : tx.value;
|
|
54
|
-
if (hexValue.length % 2 !== 0) {
|
|
55
|
-
hexValue = `0${hexValue}`;
|
|
56
|
-
}
|
|
57
|
-
bodyData.value = `0x${hexValue}`;
|
|
58
|
-
}
|
|
59
|
-
if (tx.gasLimit || tx.gas) {
|
|
60
|
-
const gasLimitValue = tx.gasLimit || tx.gas;
|
|
61
|
-
if (gasLimitValue.toString().startsWith("0x")) {
|
|
62
|
-
bodyData.gasLimit = gasLimitValue.toString();
|
|
63
|
-
} else {
|
|
64
|
-
bodyData.gasLimit = `0x${BigInt(gasLimitValue).toString(16)}`;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (tx.maxFeePerGas) {
|
|
68
|
-
if (tx.maxFeePerGas.toString().startsWith("0x")) {
|
|
69
|
-
bodyData.maxFeePerGas = tx.maxFeePerGas.toString();
|
|
70
|
-
} else {
|
|
71
|
-
bodyData.maxFeePerGas = `0x${BigInt(tx.maxFeePerGas).toString(16)}`;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (tx.maxPriorityFeePerGas) {
|
|
75
|
-
if (tx.maxPriorityFeePerGas.toString().startsWith("0x")) {
|
|
76
|
-
bodyData.maxPriorityFeePerGas = tx.maxPriorityFeePerGas.toString();
|
|
77
|
-
} else {
|
|
78
|
-
bodyData.maxPriorityFeePerGas = `0x${BigInt(tx.maxPriorityFeePerGas).toString(16)}`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
bodyData.data = tx.data || "0x";
|
|
82
|
-
const bodyString = new URLSearchParams(bodyData).toString();
|
|
83
|
-
const url = `${this.baseURL}${ABC_ENDPOINTS.SIGN_TRANSACTION}`;
|
|
84
|
-
const response = await fetch(url, {
|
|
85
|
-
method: "POST",
|
|
86
|
-
headers: {
|
|
87
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
88
|
-
"Secure-Channel": secureChannelId,
|
|
89
|
-
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
90
|
-
},
|
|
91
|
-
body: bodyString
|
|
92
|
-
});
|
|
93
|
-
const res = await response.json();
|
|
94
|
-
if (response.status === 401 && this.refreshToken) {
|
|
95
|
-
await this.refreshAccessToken();
|
|
96
|
-
const retryResponse = await fetch(url, {
|
|
97
|
-
method: "POST",
|
|
98
|
-
headers: {
|
|
99
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
100
|
-
"Secure-Channel": secureChannelId,
|
|
101
|
-
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
102
|
-
},
|
|
103
|
-
body: bodyString
|
|
104
|
-
});
|
|
105
|
-
const retryRes = await retryResponse.json();
|
|
106
|
-
if (retryRes.serializedTx && retryRes.rawTx) {
|
|
107
|
-
return {
|
|
108
|
-
signature: retryRes.serializedTx,
|
|
109
|
-
txHash: retryRes.rawTx
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
throw createAbcError(
|
|
113
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
114
|
-
"Failed to sign transaction after token refresh",
|
|
115
|
-
retryRes
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
if (res.serializedTx && res.rawTx) {
|
|
119
|
-
return {
|
|
120
|
-
signature: res.serializedTx,
|
|
121
|
-
txHash: res.rawTx
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
throw createAbcError(
|
|
125
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
126
|
-
"Failed to sign transaction",
|
|
127
|
-
res
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Sign message (Personal Sign - EIP-191)
|
|
132
|
-
*/
|
|
133
|
-
async signMessage(params) {
|
|
134
|
-
this.loadTokens();
|
|
135
|
-
const wallet = loadFromStorage("wallet" /* WALLET */);
|
|
136
|
-
if (!wallet) {
|
|
137
|
-
throw createAbcError(
|
|
138
|
-
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
139
|
-
"Wallet information not found in storage"
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
const ethers = await import("ethers");
|
|
143
|
-
const messageHash = ethers.ethers.utils.hashMessage(params.message);
|
|
144
|
-
const hash = messageHash.startsWith("0x") ? messageHash.slice(2) : messageHash;
|
|
145
|
-
const encryptedDevicePassword = await this.secure.getEncryptPlain(
|
|
146
|
-
wallet.encryptDevicePassword
|
|
147
|
-
);
|
|
148
|
-
const encryptedPvencstr = await this.secure.getEncryptPlain(
|
|
149
|
-
wallet.pvencstr
|
|
150
|
-
);
|
|
151
|
-
const encryptedWid = await this.secure.getEncryptPlain(wallet.wid);
|
|
152
|
-
const secureChannelId = await this.secure.getSecureChannelId();
|
|
153
|
-
const bodyData = {
|
|
154
|
-
hash,
|
|
155
|
-
encryptDevicePassword: encryptedDevicePassword,
|
|
156
|
-
pvencstr: encryptedPvencstr,
|
|
157
|
-
wid: encryptedWid,
|
|
158
|
-
uid: wallet.uid,
|
|
159
|
-
sid: wallet.sid
|
|
160
|
-
};
|
|
161
|
-
const bodyString = new URLSearchParams(bodyData).toString();
|
|
162
|
-
const url = `${this.baseURL}${ABC_ENDPOINTS.SIGN_HASH}`;
|
|
163
|
-
const response = await fetch(url, {
|
|
164
|
-
method: "POST",
|
|
165
|
-
headers: {
|
|
166
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
167
|
-
"Secure-Channel": secureChannelId,
|
|
168
|
-
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
169
|
-
},
|
|
170
|
-
body: bodyString
|
|
171
|
-
});
|
|
172
|
-
const text = await response.text();
|
|
173
|
-
if (!text) {
|
|
174
|
-
throw createAbcError(
|
|
175
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
176
|
-
`Empty response from sign API (status: ${response.status})`,
|
|
177
|
-
{ status: response.status }
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
const res = JSON.parse(text);
|
|
181
|
-
if (response.status === 401) {
|
|
182
|
-
if (!this.refreshToken) {
|
|
183
|
-
this.loadTokens();
|
|
184
|
-
}
|
|
185
|
-
if (this.refreshToken) {
|
|
186
|
-
await this.refreshAccessToken();
|
|
187
|
-
const retryResponse = await fetch(url, {
|
|
188
|
-
method: "POST",
|
|
189
|
-
headers: {
|
|
190
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
191
|
-
"Secure-Channel": secureChannelId,
|
|
192
|
-
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
193
|
-
},
|
|
194
|
-
body: bodyString
|
|
195
|
-
});
|
|
196
|
-
const retryText = await retryResponse.text();
|
|
197
|
-
if (!retryText) {
|
|
198
|
-
throw createAbcError(
|
|
199
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
200
|
-
`Empty response from retry (status: ${retryResponse.status})`,
|
|
201
|
-
{ status: retryResponse.status }
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
const retryRes = JSON.parse(retryText);
|
|
205
|
-
if (retryRes.status === "success" && retryRes.result?.signstr) {
|
|
206
|
-
return { signature: retryRes.result.signstr };
|
|
207
|
-
}
|
|
208
|
-
throw createAbcError(
|
|
209
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
210
|
-
"Failed to sign message after token refresh",
|
|
211
|
-
retryRes
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
if (res.signstr) {
|
|
216
|
-
const signData = JSON.parse(res.signstr);
|
|
217
|
-
const sigList = signData.sig_list?.[0];
|
|
218
|
-
if (!sigList || !sigList.r || !sigList.s) {
|
|
219
|
-
throw createAbcError(
|
|
220
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
221
|
-
"Invalid signature format",
|
|
222
|
-
res
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
const v = (sigList.vsource || 0) + 27;
|
|
226
|
-
const signature = sigList.r + sigList.s.slice(2) + v.toString(16).padStart(2, "0");
|
|
227
|
-
return { signature };
|
|
228
|
-
}
|
|
229
|
-
throw createAbcError(
|
|
230
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
231
|
-
"Failed to sign message",
|
|
232
|
-
res
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Sign typed data (EIP-712)
|
|
237
|
-
*/
|
|
238
|
-
async signTypedData(params) {
|
|
239
|
-
const wallet = loadFromStorage("wallet" /* WALLET */);
|
|
240
|
-
if (!wallet) {
|
|
241
|
-
throw createAbcError(
|
|
242
|
-
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
243
|
-
"Wallet information not found in storage"
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
const encryptedDevicePassword = await this.secure.getEncryptPlain(
|
|
247
|
-
wallet.encryptDevicePassword
|
|
248
|
-
);
|
|
249
|
-
const encryptedPvencstr = await this.secure.getEncryptPlain(
|
|
250
|
-
wallet.pvencstr
|
|
251
|
-
);
|
|
252
|
-
const encryptedWid = await this.secure.getEncryptPlain(wallet.wid);
|
|
253
|
-
const secureChannelId = await this.secure.getSecureChannelId();
|
|
254
|
-
const network = this.getNetworkName(wallet.chainId);
|
|
255
|
-
const bodyData = {
|
|
256
|
-
messageJson: params.typedData,
|
|
257
|
-
version: "v4",
|
|
258
|
-
network,
|
|
259
|
-
encryptDevicePassword: encryptedDevicePassword,
|
|
260
|
-
pvencstr: encryptedPvencstr,
|
|
261
|
-
wid: encryptedWid,
|
|
262
|
-
uid: wallet.uid,
|
|
263
|
-
sid: wallet.sid
|
|
264
|
-
};
|
|
265
|
-
const bodyString = new URLSearchParams(bodyData).toString();
|
|
266
|
-
const url = `${this.baseURL}${ABC_ENDPOINTS.SIGN_TYPED}`;
|
|
267
|
-
const response = await fetch(url, {
|
|
268
|
-
method: "POST",
|
|
269
|
-
headers: {
|
|
270
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
271
|
-
"Secure-Channel": secureChannelId,
|
|
272
|
-
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
273
|
-
},
|
|
274
|
-
body: bodyString
|
|
275
|
-
});
|
|
276
|
-
const text = await response.text();
|
|
277
|
-
if (!text) {
|
|
278
|
-
throw createAbcError(
|
|
279
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
280
|
-
`Empty response from signTypedData API (status: ${response.status})`,
|
|
281
|
-
{ status: response.status }
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
const res = JSON.parse(text);
|
|
285
|
-
if (response.status === 401 && this.refreshToken) {
|
|
286
|
-
await this.refreshAccessToken();
|
|
287
|
-
const retryResponse = await fetch(url, {
|
|
288
|
-
method: "POST",
|
|
289
|
-
headers: {
|
|
290
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
291
|
-
"Secure-Channel": secureChannelId,
|
|
292
|
-
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
293
|
-
},
|
|
294
|
-
body: bodyString
|
|
295
|
-
});
|
|
296
|
-
const retryText = await retryResponse.text();
|
|
297
|
-
if (!retryText) {
|
|
298
|
-
throw createAbcError(
|
|
299
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
300
|
-
`Empty response after retry (status: ${retryResponse.status})`,
|
|
301
|
-
{ status: retryResponse.status }
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
const retryRes = JSON.parse(retryText);
|
|
305
|
-
if (retryRes.serializedTx) {
|
|
306
|
-
return { signature: retryRes.serializedTx };
|
|
307
|
-
}
|
|
308
|
-
throw createAbcError(
|
|
309
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
310
|
-
"Failed to sign typed data after token refresh",
|
|
311
|
-
retryRes
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
if (res.serializedTx) {
|
|
315
|
-
return { signature: res.serializedTx };
|
|
316
|
-
}
|
|
317
|
-
throw createAbcError(
|
|
318
|
-
"SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
|
|
319
|
-
"Failed to sign typed data",
|
|
320
|
-
res
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Convert chainId to network name
|
|
325
|
-
*/
|
|
326
|
-
getNetworkName(chainId) {
|
|
327
|
-
const networkMap = {
|
|
328
|
-
1: "ethereum",
|
|
329
|
-
11155111: "ethereum_sepolia",
|
|
330
|
-
8217: "klaytn",
|
|
331
|
-
1001: "klaytn_baobab",
|
|
332
|
-
137: "polygon",
|
|
333
|
-
80002: "polygon_amoy",
|
|
334
|
-
42161: "arbitrum",
|
|
335
|
-
421614: "arbitrum_sepolia",
|
|
336
|
-
5e3: "mantle",
|
|
337
|
-
5003: "mantle_testnet"
|
|
338
|
-
};
|
|
339
|
-
return networkMap[chainId] || "ethereum";
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
export {
|
|
344
|
-
SigningApi
|
|
345
|
-
};
|