@talken/talkenkit 2.4.30 → 2.5.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/{AbcCredentialManager-DDHLW2IH.js → AbcCredentialManager-5W3B7GI4.js} +1 -1
- package/dist/{abcWallet-TLGPQAMU.js → abcWallet-O5IRLUXL.js} +2 -2
- package/dist/{chunk-ALBABQ53.js → chunk-PN6K4CMZ.js} +4 -1
- package/dist/{chunk-MI7TNBED.js → chunk-UHZL3WSM.js} +709 -86
- package/dist/components/TransactionResultModal/TransactionResultModal.css.d.ts +17 -0
- package/dist/components/TransactionResultModal/TransactionResultModal.d.ts +9 -0
- package/dist/index.css +138 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1344 -980
- package/dist/providers/TransactionResultProvider/TransactionResultContext.d.ts +6 -0
- package/dist/providers/TransactionResultProvider/TransactionResultProvider.d.ts +7 -0
- package/dist/providers/TransactionResultProvider/TransactionResultSingleton.d.ts +16 -0
- package/dist/providers/TransactionResultProvider/index.d.ts +4 -0
- package/dist/providers/TransactionResultProvider/types.d.ts +14 -0
- package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.d.ts +69 -0
- package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.js +11 -0
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +8 -6
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +8 -0
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +5 -4
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +8 -8
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.d.ts +7 -0
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +9 -7
- package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +25 -0
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +9 -9
- package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +3 -0
- package/dist/wallets/walletConnectors/abcWallet/constants.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/index.d.ts +1 -1
- package/dist/wallets/walletConnectors/abcWallet/index.js +35 -33
- package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/types.d.ts +11 -0
- package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +3 -3
- package/dist/wallets/walletConnectors/{chunk-VDWJ3NQ5.js → chunk-25ZDAJ3L.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-4JZPP3S7.js +380 -0
- package/dist/wallets/walletConnectors/{chunk-HHZ3JZRH.js → chunk-4YEALKXG.js} +74 -14
- package/dist/wallets/walletConnectors/{chunk-IN3HEGZM.js → chunk-645DT4TS.js} +46 -5
- package/dist/wallets/walletConnectors/{chunk-XNA5NIFE.js → chunk-6TAU7OQK.js} +7 -4
- package/dist/wallets/walletConnectors/{chunk-MO2AXXLI.js → chunk-FKI5AZVH.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-JADQLTFW.js → chunk-H2AZTZMM.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-NULM3THX.js → chunk-HWRZGGGN.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-BHEVY4QY.js → chunk-KIYXONNH.js} +35 -2
- package/dist/wallets/walletConnectors/{chunk-NU3ITJNK.js → chunk-L6FCF3FH.js} +94 -736
- package/dist/wallets/walletConnectors/{chunk-ACLPF2UW.js → chunk-LIGH2LEU.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-OASBABPG.js +746 -0
- package/dist/wallets/walletConnectors/{chunk-A66MTFML.js → chunk-PF65YS3T.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-6WF4SXLB.js → chunk-QKK3OPQA.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-3LF7FVL6.js → chunk-RGYZNNB6.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-DPTDOCWL.js → chunk-RX2VOIUB.js} +4 -1
- package/dist/wallets/walletConnectors/{chunk-YV6IZWGE.js → chunk-URS2KVYK.js} +45 -2
- package/dist/wallets/walletConnectors/{chunk-BXH3GDX5.js → chunk-YKFI6ZGM.js} +1 -1
- package/dist/wallets/walletConnectors/index.js +47 -45
- package/package.json +1 -1
- package/dist/wallets/walletConnectors/chunk-CABLJOMU.js +0 -194
- package/dist/wallets/walletConnectors/chunk-J3YPHDHM.js +0 -827
- package/dist/wallets/walletConnectors/chunk-J566FC7T.js +0 -54
- package/dist/wallets/walletConnectors/chunk-OHQXPSR6.js +0 -300
- package/dist/wallets/walletConnectors/chunk-OMOYFHBT.js +0 -1485
|
@@ -165,12 +165,15 @@ var TALKEN_API_ENDPOINTS = {
|
|
|
165
165
|
SOLANA_TX_STATUS: "/wallet/solana/tx-status",
|
|
166
166
|
TX_BTC: "/wallet/tx/btc",
|
|
167
167
|
TX_TVM: "/wallet/tx/tvm",
|
|
168
|
+
TRON_UTIL: "/wallet/tron",
|
|
168
169
|
// ── Gas (WaaS proxy) ───────────────────────────────────────────────
|
|
169
170
|
GAS_PRICE: "/wallet/gas/price",
|
|
170
171
|
GAS_SUGGESTED: "/wallet/gas/suggested",
|
|
171
172
|
GAS_ESTIMATE: "/wallet/gas/estimate",
|
|
172
|
-
// ── Nonce (WaaS proxy)
|
|
173
|
+
// ── Nonce / Balance / eth_call (WaaS proxy) ───────────────────────
|
|
173
174
|
NONCE: "/wallet/nonce",
|
|
175
|
+
ADDRESS_BALANCE: "/wallet/address/balance",
|
|
176
|
+
ETH_CALL: "/wallet/contract/eth-call",
|
|
174
177
|
// ── Relayer ────────────────────────────────────────────────────────
|
|
175
178
|
RELAYER_FEE_ESTIMATE: "/relayer/estimate-fee",
|
|
176
179
|
// ── Config / Runtime ───────────────────────────────────────────────
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
getCredentialManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QKK3OPQA.js";
|
|
5
5
|
|
|
6
6
|
// src/wallets/walletConnectors/abcWallet/abcTronProvider.ts
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
getShowPendingTransaction,
|
|
9
|
+
getTalkenApiClient,
|
|
10
|
+
getUpdateTransactionResult
|
|
11
|
+
} from "@talken/talkenkit";
|
|
8
12
|
import { keccak256 } from "viem";
|
|
9
13
|
function isTalkenApiClient(client) {
|
|
10
14
|
return typeof client?.tron?.transferTrx === "function";
|
|
@@ -325,6 +329,7 @@ ${msgBytes.length}`
|
|
|
325
329
|
toAddress: params.toAddress,
|
|
326
330
|
amountSun: amountRaw,
|
|
327
331
|
pin: pinHash,
|
|
332
|
+
waitForConfirmation: true,
|
|
328
333
|
...email && { email }
|
|
329
334
|
} : {
|
|
330
335
|
kind: "trc20",
|
|
@@ -334,10 +339,21 @@ ${msgBytes.length}`
|
|
|
334
339
|
amount: amountRaw,
|
|
335
340
|
feeLimit: params.feeLimit,
|
|
336
341
|
pin: pinHash,
|
|
342
|
+
waitForConfirmation: true,
|
|
337
343
|
...email && { email }
|
|
338
344
|
};
|
|
345
|
+
const showPending = getShowPendingTransaction();
|
|
346
|
+
if (showPending) {
|
|
347
|
+
showPending({
|
|
348
|
+
txHash: "",
|
|
349
|
+
network: this.network.type,
|
|
350
|
+
chain: "tron",
|
|
351
|
+
explorerUrl: void 0
|
|
352
|
+
});
|
|
353
|
+
}
|
|
339
354
|
const result = await api.tron.transferTrx(request);
|
|
340
355
|
const txHash = result.txHash;
|
|
356
|
+
this.updateTransactionResult(result);
|
|
341
357
|
console.log(
|
|
342
358
|
`[TronProvider] \u2705 ${txType === "NATIVE" ? "TRX" : "TRC-20"} transaction complete via TalkenApiClient:`,
|
|
343
359
|
txHash
|
|
@@ -384,6 +400,33 @@ ${msgBytes.length}`
|
|
|
384
400
|
network: this.network.type
|
|
385
401
|
};
|
|
386
402
|
}
|
|
403
|
+
updateTransactionResult(result) {
|
|
404
|
+
const updateResult = getUpdateTransactionResult();
|
|
405
|
+
if (!updateResult)
|
|
406
|
+
return;
|
|
407
|
+
let receipt = result.receipt;
|
|
408
|
+
if (!receipt && result.confirmation) {
|
|
409
|
+
const conf = result.confirmation;
|
|
410
|
+
const info = conf?.info ?? conf;
|
|
411
|
+
const tx = conf?.transaction ?? conf;
|
|
412
|
+
const blockNumber = info?.blockNumber ?? info?.result?.blockNumber ?? null;
|
|
413
|
+
const rcpt = info?.receipt ?? info?.result?.receipt;
|
|
414
|
+
const ret = tx?.ret ?? tx?.result?.ret;
|
|
415
|
+
const contractRet = Array.isArray(ret) ? ret[0]?.contractRet : void 0;
|
|
416
|
+
receipt = {
|
|
417
|
+
status: contractRet === "SUCCESS" ? 1 : contractRet ? 0 : null,
|
|
418
|
+
blockNumber,
|
|
419
|
+
gasUsed: rcpt?.energy_usage_total != null ? String(rcpt.energy_usage_total) : null
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
updateResult({
|
|
423
|
+
txHash: result.txHash,
|
|
424
|
+
network: this.network.type,
|
|
425
|
+
chain: "tron",
|
|
426
|
+
receipt,
|
|
427
|
+
explorerUrl: `${this.network.explorer}/#/transaction/${result.txHash}`
|
|
428
|
+
});
|
|
429
|
+
}
|
|
387
430
|
};
|
|
388
431
|
|
|
389
432
|
export {
|
|
@@ -1,47 +1,46 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
abcWallet
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6TAU7OQK.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
argentWallet
|
|
7
|
+
} from "./chunk-XT2WYPN5.js";
|
|
8
|
+
import "./chunk-4YEALKXG.js";
|
|
9
9
|
import "./chunk-R6ZE7JAZ.js";
|
|
10
10
|
import "./chunk-GFWUFYT2.js";
|
|
11
|
+
import "./chunk-KIYXONNH.js";
|
|
12
|
+
import "./chunk-4JZPP3S7.js";
|
|
11
13
|
import "./chunk-O4AU63LK.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-L6FCF3FH.js";
|
|
15
|
+
import "./chunk-OASBABPG.js";
|
|
16
|
+
import "./chunk-PF65YS3T.js";
|
|
15
17
|
import "./chunk-4P3SPC44.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-QKK3OPQA.js";
|
|
19
|
+
import "./chunk-RX2VOIUB.js";
|
|
18
20
|
import {
|
|
19
21
|
tokenaryWallet
|
|
20
22
|
} from "./chunk-U24COF36.js";
|
|
21
|
-
import {
|
|
22
|
-
trustWallet
|
|
23
|
-
} from "./chunk-S2PY4MDO.js";
|
|
24
23
|
import {
|
|
25
24
|
uniswapWallet
|
|
26
25
|
} from "./chunk-DLDZUVTB.js";
|
|
27
26
|
import {
|
|
28
27
|
valoraWallet
|
|
29
28
|
} from "./chunk-CVUEWUDI.js";
|
|
30
|
-
import {
|
|
31
|
-
walletConnectWallet
|
|
32
|
-
} from "./chunk-KU5R3WAJ.js";
|
|
33
29
|
import {
|
|
34
30
|
wigwamWallet
|
|
35
31
|
} from "./chunk-EFYKBPOB.js";
|
|
36
32
|
import {
|
|
37
|
-
|
|
38
|
-
} from "./chunk-
|
|
33
|
+
walletConnectWallet
|
|
34
|
+
} from "./chunk-KU5R3WAJ.js";
|
|
39
35
|
import {
|
|
40
36
|
zealWallet
|
|
41
37
|
} from "./chunk-SCOX5RF4.js";
|
|
42
38
|
import {
|
|
43
|
-
|
|
44
|
-
} from "./chunk-
|
|
39
|
+
zerionWallet
|
|
40
|
+
} from "./chunk-53IBFGVW.js";
|
|
41
|
+
import {
|
|
42
|
+
xdefiWallet
|
|
43
|
+
} from "./chunk-26RJNF7V.js";
|
|
45
44
|
import {
|
|
46
45
|
safeheronWallet
|
|
47
46
|
} from "./chunk-PHF4VWKP.js";
|
|
@@ -64,8 +63,8 @@ import {
|
|
|
64
63
|
tokenPocketWallet
|
|
65
64
|
} from "./chunk-5NM2LK2G.js";
|
|
66
65
|
import {
|
|
67
|
-
|
|
68
|
-
} from "./chunk-
|
|
66
|
+
trustWallet
|
|
67
|
+
} from "./chunk-S2PY4MDO.js";
|
|
69
68
|
import {
|
|
70
69
|
oneKeyWallet
|
|
71
70
|
} from "./chunk-6UGYPEQE.js";
|
|
@@ -88,20 +87,20 @@ import {
|
|
|
88
87
|
roninWallet
|
|
89
88
|
} from "./chunk-D7U5WEH2.js";
|
|
90
89
|
import {
|
|
91
|
-
|
|
92
|
-
} from "./chunk-
|
|
90
|
+
safeWallet
|
|
91
|
+
} from "./chunk-Z2QCE6O6.js";
|
|
93
92
|
import {
|
|
94
93
|
magicEdenWallet
|
|
95
94
|
} from "./chunk-WB7EEKPS.js";
|
|
96
95
|
import {
|
|
97
96
|
metaMaskWallet
|
|
98
97
|
} from "./chunk-AKLKCDXT.js";
|
|
99
|
-
import {
|
|
100
|
-
mewWallet
|
|
101
|
-
} from "./chunk-ZRY6ILYP.js";
|
|
102
98
|
import {
|
|
103
99
|
nestWallet
|
|
104
100
|
} from "./chunk-NN4KGG3I.js";
|
|
101
|
+
import {
|
|
102
|
+
mewWallet
|
|
103
|
+
} from "./chunk-ZRY6ILYP.js";
|
|
105
104
|
import {
|
|
106
105
|
oktoWallet
|
|
107
106
|
} from "./chunk-7SSXG35M.js";
|
|
@@ -111,6 +110,9 @@ import {
|
|
|
111
110
|
import {
|
|
112
111
|
omniWallet
|
|
113
112
|
} from "./chunk-RGPO7AY3.js";
|
|
113
|
+
import {
|
|
114
|
+
oneInchWallet
|
|
115
|
+
} from "./chunk-OJT577AY.js";
|
|
114
116
|
import {
|
|
115
117
|
injectedWallet
|
|
116
118
|
} from "./chunk-GDGRUMZB.js";
|
|
@@ -118,44 +120,44 @@ import {
|
|
|
118
120
|
iopayWallet
|
|
119
121
|
} from "./chunk-2W6UBYKX.js";
|
|
120
122
|
import {
|
|
121
|
-
|
|
122
|
-
} from "./chunk-
|
|
123
|
+
kaiaWallet
|
|
124
|
+
} from "./chunk-C7S72VGD.js";
|
|
123
125
|
import {
|
|
124
126
|
kaikasWallet
|
|
125
127
|
} from "./chunk-BJYSWRV6.js";
|
|
126
|
-
import {
|
|
127
|
-
kaiaWallet
|
|
128
|
-
} from "./chunk-C7S72VGD.js";
|
|
129
128
|
import {
|
|
130
129
|
krakenWallet
|
|
131
130
|
} from "./chunk-CYOZFCR6.js";
|
|
132
131
|
import {
|
|
133
132
|
kresusWallet
|
|
134
133
|
} from "./chunk-CM3VR7OM.js";
|
|
134
|
+
import {
|
|
135
|
+
ledgerWallet
|
|
136
|
+
} from "./chunk-BF3VSNPL.js";
|
|
135
137
|
import {
|
|
136
138
|
dawnWallet
|
|
137
139
|
} from "./chunk-YMP3W2MO.js";
|
|
138
140
|
import {
|
|
139
141
|
desigWallet
|
|
140
142
|
} from "./chunk-DVXPOWEC.js";
|
|
143
|
+
import {
|
|
144
|
+
enkryptWallet
|
|
145
|
+
} from "./chunk-5QHPQU7J.js";
|
|
141
146
|
import {
|
|
142
147
|
foxWallet
|
|
143
148
|
} from "./chunk-K6GEK4JB.js";
|
|
144
149
|
import {
|
|
145
150
|
frameWallet
|
|
146
151
|
} from "./chunk-CP45RGL4.js";
|
|
147
|
-
import {
|
|
148
|
-
enkryptWallet
|
|
149
|
-
} from "./chunk-5QHPQU7J.js";
|
|
150
152
|
import {
|
|
151
153
|
gateWallet
|
|
152
154
|
} from "./chunk-K6UZPSBG.js";
|
|
153
|
-
import {
|
|
154
|
-
frontierWallet
|
|
155
|
-
} from "./chunk-JWO4ZQLK.js";
|
|
156
155
|
import {
|
|
157
156
|
imTokenWallet
|
|
158
157
|
} from "./chunk-EHE2536P.js";
|
|
158
|
+
import {
|
|
159
|
+
frontierWallet
|
|
160
|
+
} from "./chunk-JWO4ZQLK.js";
|
|
159
161
|
import {
|
|
160
162
|
bloomWallet
|
|
161
163
|
} from "./chunk-3KPCADAF.js";
|
|
@@ -168,12 +170,12 @@ import {
|
|
|
168
170
|
import {
|
|
169
171
|
clvWallet
|
|
170
172
|
} from "./chunk-3IVTKZ7V.js";
|
|
171
|
-
import {
|
|
172
|
-
coin98Wallet
|
|
173
|
-
} from "./chunk-GILMNC3J.js";
|
|
174
173
|
import {
|
|
175
174
|
coinbaseWallet
|
|
176
175
|
} from "./chunk-PNEDRY6O.js";
|
|
176
|
+
import {
|
|
177
|
+
coin98Wallet
|
|
178
|
+
} from "./chunk-GILMNC3J.js";
|
|
177
179
|
import {
|
|
178
180
|
compassWallet
|
|
179
181
|
} from "./chunk-3OO564GS.js";
|
|
@@ -181,14 +183,14 @@ import {
|
|
|
181
183
|
coreWallet
|
|
182
184
|
} from "./chunk-FBI7UGNO.js";
|
|
183
185
|
import {
|
|
184
|
-
|
|
185
|
-
} from "./chunk-
|
|
186
|
-
import {
|
|
187
|
-
bestWallet
|
|
188
|
-
} from "./chunk-OPAPBEA5.js";
|
|
186
|
+
berasigWallet
|
|
187
|
+
} from "./chunk-KM55XFBI.js";
|
|
189
188
|
import {
|
|
190
189
|
bifrostWallet
|
|
191
190
|
} from "./chunk-B6DM7J4N.js";
|
|
191
|
+
import {
|
|
192
|
+
bestWallet
|
|
193
|
+
} from "./chunk-OPAPBEA5.js";
|
|
192
194
|
import {
|
|
193
195
|
binanceWallet
|
|
194
196
|
} from "./chunk-4T3UOJYR.js";
|
package/package.json
CHANGED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
getBitcoinNetwork,
|
|
4
|
-
getEvmNetwork,
|
|
5
|
-
getSolanaNetwork,
|
|
6
|
-
getTronNetwork
|
|
7
|
-
} from "./chunk-O4AU63LK.js";
|
|
8
|
-
import {
|
|
9
|
-
getCredentialManager
|
|
10
|
-
} from "./chunk-6WF4SXLB.js";
|
|
11
|
-
import {
|
|
12
|
-
AbcError
|
|
13
|
-
} from "./chunk-4P3SPC44.js";
|
|
14
|
-
|
|
15
|
-
// src/wallets/walletConnectors/abcWallet/walletGeneration.ts
|
|
16
|
-
import { getTalkenApiClient } from "@talken/talkenkit";
|
|
17
|
-
async function mapApiResponseToWallets(genResponse, infoResponse, email) {
|
|
18
|
-
const accounts = infoResponse?.accounts || [];
|
|
19
|
-
const evmAccount = accounts[0] || infoResponse || {};
|
|
20
|
-
const uid = String(genResponse.uid || evmAccount.uid || "");
|
|
21
|
-
const wid = String(genResponse.wid || evmAccount.wid || "");
|
|
22
|
-
const sid = String(
|
|
23
|
-
evmAccount.sid || evmAccount.ethAddress || genResponse.evmAddress || ""
|
|
24
|
-
);
|
|
25
|
-
const pubkey = String(evmAccount.pubkey || genResponse.pubkey || "");
|
|
26
|
-
const solMaterial = genResponse.solana || {};
|
|
27
|
-
let btcAddress = genResponse.btcAddress || "";
|
|
28
|
-
let trxAddress = genResponse.trxAddress || "";
|
|
29
|
-
if ((!btcAddress || !trxAddress) && pubkey) {
|
|
30
|
-
try {
|
|
31
|
-
const api = getTalkenApiClient();
|
|
32
|
-
if (api) {
|
|
33
|
-
const addrResponse = await api.wallet.getAddressForChain("all");
|
|
34
|
-
if (!btcAddress)
|
|
35
|
-
btcAddress = addrResponse?.btc || addrResponse?.btcAddress || "";
|
|
36
|
-
if (!trxAddress)
|
|
37
|
-
trxAddress = addrResponse?.trx || addrResponse?.trxAddress || "";
|
|
38
|
-
}
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.warn(
|
|
41
|
-
"[walletGeneration] Failed to derive BTC/TRX addresses:",
|
|
42
|
-
err
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const pvencstr = String(evmAccount.pvencstr || "");
|
|
47
|
-
const edp = String(evmAccount.encryptDevicePassword || "");
|
|
48
|
-
if (uid && wid && sid && pvencstr && edp) {
|
|
49
|
-
getCredentialManager().setEvmSigningCredentials({
|
|
50
|
-
uid,
|
|
51
|
-
wid,
|
|
52
|
-
sid,
|
|
53
|
-
pvencstr,
|
|
54
|
-
encryptDevicePassword: edp
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const evmWallet = {
|
|
58
|
-
uid,
|
|
59
|
-
sessionId: sid,
|
|
60
|
-
keyId: wid,
|
|
61
|
-
encryptedShare: pvencstr,
|
|
62
|
-
secretStore: edp,
|
|
63
|
-
address: genResponse.evmAddress || sid,
|
|
64
|
-
chainId: getEvmNetwork(),
|
|
65
|
-
sid,
|
|
66
|
-
type: "evm",
|
|
67
|
-
email,
|
|
68
|
-
pubkey
|
|
69
|
-
};
|
|
70
|
-
const solanaWallet = {
|
|
71
|
-
uid,
|
|
72
|
-
sessionId: String(solMaterial.shareId || ""),
|
|
73
|
-
keyId: String(solMaterial.keyId || ""),
|
|
74
|
-
encryptedShare: String(solMaterial.encryptedShare || ""),
|
|
75
|
-
secretStore: String(solMaterial.secretStore || ""),
|
|
76
|
-
shareId: String(solMaterial.shareId || ""),
|
|
77
|
-
publicKey: String(solMaterial.publicKey || ""),
|
|
78
|
-
address: genResponse.solAddress || solMaterial.address || "",
|
|
79
|
-
network: getSolanaNetwork()
|
|
80
|
-
};
|
|
81
|
-
const bitcoinWallet = {
|
|
82
|
-
uid,
|
|
83
|
-
sessionId: sid,
|
|
84
|
-
keyId: wid,
|
|
85
|
-
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
86
|
-
shareId: sid,
|
|
87
|
-
publicKey: pubkey,
|
|
88
|
-
address: btcAddress,
|
|
89
|
-
addressType: "bech32",
|
|
90
|
-
network: getBitcoinNetwork()
|
|
91
|
-
};
|
|
92
|
-
const tronWallet = {
|
|
93
|
-
uid,
|
|
94
|
-
sessionId: sid,
|
|
95
|
-
keyId: wid,
|
|
96
|
-
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
97
|
-
shareId: sid,
|
|
98
|
-
publicKey: pubkey,
|
|
99
|
-
address: trxAddress,
|
|
100
|
-
network: getTronNetwork()
|
|
101
|
-
};
|
|
102
|
-
return { evmWallet, solanaWallet, bitcoinWallet, tronWallet };
|
|
103
|
-
}
|
|
104
|
-
async function generateMpcWallets(hashedPin, email) {
|
|
105
|
-
const api = getTalkenApiClient();
|
|
106
|
-
if (!api) {
|
|
107
|
-
throw new AbcError(
|
|
108
|
-
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
109
|
-
"TalkenApiClient not initialized"
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
const genResponse = await api.wallet.generate(hashedPin, email);
|
|
114
|
-
const infoResponse = await api.wallet.getInfo().catch(() => ({}));
|
|
115
|
-
return await mapApiResponseToWallets(
|
|
116
|
-
genResponse,
|
|
117
|
-
infoResponse,
|
|
118
|
-
email || ""
|
|
119
|
-
);
|
|
120
|
-
} catch (error) {
|
|
121
|
-
throw new AbcError(
|
|
122
|
-
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
123
|
-
`Failed to generate MPC wallets: ${error.message}`,
|
|
124
|
-
{ originalError: error }
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function recoverMpcWallets(hashedPin, email) {
|
|
129
|
-
const api = getTalkenApiClient();
|
|
130
|
-
if (!api) {
|
|
131
|
-
throw new AbcError(
|
|
132
|
-
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
133
|
-
"TalkenApiClient not initialized"
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
try {
|
|
137
|
-
const genResponse = await api.wallet.recover(hashedPin, email);
|
|
138
|
-
const infoResponse = await api.wallet.getInfo().catch(() => ({}));
|
|
139
|
-
return await mapApiResponseToWallets(
|
|
140
|
-
genResponse,
|
|
141
|
-
infoResponse,
|
|
142
|
-
email || ""
|
|
143
|
-
);
|
|
144
|
-
} catch (error) {
|
|
145
|
-
throw new AbcError(
|
|
146
|
-
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
147
|
-
`Failed to recover MPC wallets: ${error.message}`,
|
|
148
|
-
{ originalError: error }
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function validateMpcWallets(result) {
|
|
153
|
-
const errors = [];
|
|
154
|
-
if (!result.evmWallet) {
|
|
155
|
-
errors.push("EVM wallet is missing");
|
|
156
|
-
} else {
|
|
157
|
-
if (!result.evmWallet.address || !result.evmWallet.address.startsWith("0x")) {
|
|
158
|
-
errors.push("Invalid EVM wallet address");
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (!result.solanaWallet) {
|
|
162
|
-
errors.push("Solana wallet is missing");
|
|
163
|
-
} else {
|
|
164
|
-
if (!result.solanaWallet.address) {
|
|
165
|
-
errors.push("Invalid Solana wallet address");
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (!result.bitcoinWallet) {
|
|
169
|
-
errors.push("Bitcoin wallet is missing");
|
|
170
|
-
} else {
|
|
171
|
-
if (!result.bitcoinWallet.address) {
|
|
172
|
-
errors.push("Invalid Bitcoin wallet address");
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (!result.tronWallet) {
|
|
176
|
-
errors.push("TRON wallet is missing");
|
|
177
|
-
} else {
|
|
178
|
-
if (!result.tronWallet.address) {
|
|
179
|
-
errors.push("Invalid TRON wallet address");
|
|
180
|
-
} else if (!result.tronWallet.address.startsWith("T")) {
|
|
181
|
-
errors.push("Invalid TRON address format (expected T prefix)");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return {
|
|
185
|
-
valid: errors.length === 0,
|
|
186
|
-
errors
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export {
|
|
191
|
-
generateMpcWallets,
|
|
192
|
-
recoverMpcWallets,
|
|
193
|
-
validateMpcWallets
|
|
194
|
-
};
|