@talken/talkenkit 2.7.5-beta.2 → 2.7.5-beta.3
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-6FBGTSSM.js +7 -0
- package/dist/abcWallet-6BIO6Q6T.js +184 -0
- package/dist/chunk-PZ4TCLAJ.js +7816 -0
- package/dist/chunk-SUYKWM5G.js +451 -0
- package/dist/components/ConfirmationModal/NonEvmSignConfirmationModal.d.ts +1 -1
- package/dist/components/ConfirmationModal/NonEvmTransferConfirmationModal.d.ts +1 -1
- package/dist/components/ConfirmationModal/SignConfirmationModal.d.ts +1 -1
- package/dist/components/ConfirmationModal/TransactionConfirmationModal.d.ts +2 -1
- package/dist/components/ConfirmationModal/constants.d.ts +0 -4
- package/dist/components/RainbowKitProvider/RainbowKitProvider.d.ts +31 -1
- package/dist/components/TransactionResultModal/TransactionResultModal.css.d.ts +3 -0
- package/dist/components/TransactionResultModal/TransactionResultModal.d.ts +1 -1
- package/dist/config/networks.d.ts +2 -1
- package/dist/gasless/GaslessConfigSingleton.d.ts +11 -0
- package/dist/gasless/api/ChainConfigApi.d.ts +20 -0
- package/dist/gasless/api/RelayerApi.d.ts +25 -0
- package/dist/gasless/api/TokenCapabilityApi.d.ts +12 -0
- package/dist/gasless/config.d.ts +12 -0
- package/dist/gasless/hooks/useGaslessTransfer.d.ts +18 -0
- package/dist/gasless/index.d.ts +12 -0
- package/dist/gasless/services/Eip7702Service.d.ts +80 -0
- package/dist/gasless/services/GaslessFeeService.d.ts +55 -0
- package/dist/gasless/services/GaslessTransferService.d.ts +61 -0
- package/dist/gasless/services/PermitSignService.d.ts +28 -0
- package/dist/gasless/signer/AbcWaasSigner.d.ts +27 -0
- package/dist/gasless/signer/GaslessSigner.d.ts +43 -0
- package/dist/gasless/signer/WagmiSigner.d.ts +63 -0
- package/dist/gasless/signer/index.d.ts +4 -0
- package/dist/gasless/types.d.ts +298 -0
- package/dist/gasless/utils/delegationGuard.d.ts +50 -0
- package/dist/gasless/utils/feeTokenResolver.d.ts +35 -0
- package/dist/gasless/utils/revokeDelegation.d.ts +55 -0
- package/dist/gasless/utils/transferDetector.d.ts +20 -0
- package/dist/hooks/internal/abcEmbeddedWallet.d.ts +1 -1
- package/dist/hooks/useXrplWallet.d.ts +77 -0
- package/dist/index.css +41 -37
- package/dist/index.d.ts +7 -2
- package/dist/index.js +2282 -1448
- package/dist/providers/AbcAuthProvider.d.ts +2 -1
- package/dist/providers/SignConfirmationProvider/SignConfirmationProvider.d.ts +1 -1
- package/dist/providers/SignConfirmationProvider/index.d.ts +1 -1
- package/dist/providers/SignConfirmationProvider/types.d.ts +14 -1
- package/dist/providers/SignConfirmationProvider/useTransactionResolver.d.ts +2 -1
- package/dist/providers/TransactionResultProvider/types.d.ts +7 -1
- package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.d.ts +2 -0
- package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +5 -5
- package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.d.ts +5 -0
- package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/ProviderError.d.ts +3 -0
- package/dist/wallets/walletConnectors/abcWallet/ProviderError.js +5 -3
- package/dist/wallets/walletConnectors/abcWallet/StorageService.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +8 -8
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +7 -7
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +22 -21
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +16 -0
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +11 -11
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +22 -21
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +7 -7
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +23 -22
- package/dist/wallets/walletConnectors/abcWallet/abcXrplProvider.d.ts +99 -0
- package/dist/wallets/walletConnectors/abcWallet/abcXrplProvider.js +19 -0
- package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +3 -0
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +15 -14
- 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 +20 -19
- package/dist/wallets/walletConnectors/abcWallet/api/modules/auth.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/modules/bitcoin.js +5 -5
- package/dist/wallets/walletConnectors/abcWallet/api/modules/evm.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/modules/solana.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/modules/tron.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/modules/wallet.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/modules/walletscan.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/modules/xrp.d.ts +85 -0
- package/dist/wallets/walletConnectors/abcWallet/api/modules/xrp.js +8 -0
- package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +9 -0
- package/dist/wallets/walletConnectors/abcWallet/constants.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/index.d.ts +5 -0
- package/dist/wallets/walletConnectors/abcWallet/index.js +71 -56
- package/dist/wallets/walletConnectors/abcWallet/networkConfig.d.ts +31 -3
- package/dist/wallets/walletConnectors/abcWallet/networkConfig.js +11 -3
- package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/types/api.types.d.ts +3 -1
- package/dist/wallets/walletConnectors/abcWallet/types/auth.types.d.ts +3 -1
- package/dist/wallets/walletConnectors/abcWallet/types/config.types.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/types/config.types.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/types/wallet.types.d.ts +15 -1
- package/dist/wallets/walletConnectors/abcWallet/types.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/utils.js +5 -5
- package/dist/wallets/walletConnectors/abcWallet/walletGeneration.d.ts +2 -1
- package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +8 -8
- package/dist/wallets/walletConnectors/berasigWallet/berasigWallet.js +2 -2
- package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
- package/dist/wallets/walletConnectors/binanceWallet/binanceWallet.js +2 -2
- package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
- package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
- package/dist/wallets/walletConnectors/chunk-2LH53QET.js +71 -0
- package/dist/wallets/walletConnectors/chunk-2LOET2LX.js +64 -0
- package/dist/wallets/walletConnectors/chunk-2XNFYA54.js +492 -0
- package/dist/wallets/walletConnectors/chunk-326CQ42T.js +378 -0
- package/dist/wallets/walletConnectors/chunk-3NWM24MH.js +61 -0
- package/dist/wallets/walletConnectors/chunk-3Z5DO42M.js +240 -0
- package/dist/wallets/walletConnectors/chunk-4Y7YP4IR.js +115 -0
- package/dist/wallets/walletConnectors/chunk-AJ2YNYCD.js +277 -0
- package/dist/wallets/walletConnectors/chunk-BOHX6ZNO.js +3030 -0
- package/dist/wallets/walletConnectors/chunk-E4B4UELA.js +3030 -0
- package/dist/wallets/walletConnectors/chunk-F74FF7OS.js +370 -0
- package/dist/wallets/walletConnectors/chunk-FWX2HD26.js +30 -0
- package/dist/wallets/walletConnectors/chunk-ICGK5DGY.js +146 -0
- package/dist/wallets/walletConnectors/chunk-IGZOEVKN.js +58 -0
- package/dist/wallets/walletConnectors/chunk-IJJQA3AB.js +218 -0
- package/dist/wallets/walletConnectors/chunk-JU6AJBYS.js +20 -0
- package/dist/wallets/walletConnectors/chunk-KTVJLN3O.js +58 -0
- package/dist/wallets/walletConnectors/chunk-L3EPZ4NZ.js +52 -0
- package/dist/wallets/walletConnectors/chunk-LQI5HRAB.js +218 -0
- package/dist/wallets/walletConnectors/chunk-LTN4JK3R.js +340 -0
- package/dist/wallets/walletConnectors/chunk-MGVZ2TUF.js +318 -0
- package/dist/wallets/walletConnectors/chunk-MU46EEQT.js +128 -0
- package/dist/wallets/walletConnectors/chunk-MY7UE4VE.js +240 -0
- package/dist/wallets/walletConnectors/chunk-NEMEHJ72.js +93 -0
- package/dist/wallets/walletConnectors/chunk-NF72HTDP.js +378 -0
- package/dist/wallets/walletConnectors/chunk-QI5BHIHY.js +318 -0
- package/dist/wallets/walletConnectors/chunk-QLPGMWGT.js +132 -0
- package/dist/wallets/walletConnectors/chunk-QODJUJ3A.js +370 -0
- package/dist/wallets/walletConnectors/chunk-TBWPVX5M.js +148 -0
- package/dist/wallets/walletConnectors/chunk-TLRR3FFT.js +132 -0
- package/dist/wallets/walletConnectors/chunk-TM6YD43A.js +341 -0
- package/dist/wallets/walletConnectors/chunk-TYJR3KGY.js +46 -0
- package/dist/wallets/walletConnectors/chunk-UPQCNBIW.js +341 -0
- package/dist/wallets/walletConnectors/chunk-VVXSRRXI.js +189 -0
- package/dist/wallets/walletConnectors/chunk-WHL6MSKS.js +492 -0
- package/dist/wallets/walletConnectors/chunk-WZ4ZJB74.js +340 -0
- package/dist/wallets/walletConnectors/chunk-X3DT5G3F.js +215 -0
- package/dist/wallets/walletConnectors/chunk-XDNFWX2X.js +199 -0
- package/dist/wallets/walletConnectors/chunk-YNE2UX2Z.js +137 -0
- package/dist/wallets/walletConnectors/chunk-YXWHHI4S.js +64 -0
- package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
- package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
- package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
- package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
- package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
- package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
- package/dist/wallets/walletConnectors/index.js +109 -108
- package/dist/wallets/walletConnectors/iopayWallet/iopayWallet.js +2 -2
- package/dist/wallets/walletConnectors/kaiaWallet/kaiaWallet.js +2 -2
- package/dist/wallets/walletConnectors/kaikasWallet/kaikasWallet.js +2 -2
- package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
- package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
- package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
- package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
- package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
- package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
- package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
- package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
- package/dist/wallets/walletConnectors/zealWallet/zealWallet.js +2 -2
- package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getBitcoinNetwork,
|
|
4
|
+
getEvmNetwork,
|
|
5
|
+
getSolanaNetwork,
|
|
6
|
+
getTronNetwork,
|
|
7
|
+
getXrplNetwork
|
|
8
|
+
} from "./chunk-X3DT5G3F.js";
|
|
9
|
+
import {
|
|
10
|
+
AbcError
|
|
11
|
+
} from "./chunk-BUAWEYGV.js";
|
|
12
|
+
import {
|
|
13
|
+
createLogger
|
|
14
|
+
} from "./chunk-762I67R6.js";
|
|
15
|
+
import {
|
|
16
|
+
getCredentialManager
|
|
17
|
+
} from "./chunk-YNE2UX2Z.js";
|
|
18
|
+
|
|
19
|
+
// src/wallets/walletConnectors/abcWallet/walletGeneration.ts
|
|
20
|
+
import { getTalkenApiClient } from "@talken/talkenkit";
|
|
21
|
+
var logger = createLogger("WalletGeneration");
|
|
22
|
+
async function mapApiResponseToWallets(genResponse, infoResponse, email) {
|
|
23
|
+
const accounts = infoResponse?.accounts || [];
|
|
24
|
+
const evmAccount = accounts[0] || infoResponse || {};
|
|
25
|
+
const uid = String(genResponse.uid || evmAccount.uid || "");
|
|
26
|
+
const wid = String(genResponse.wid || evmAccount.wid || "");
|
|
27
|
+
const sid = String(
|
|
28
|
+
evmAccount.sid || evmAccount.ethAddress || genResponse.evmAddress || ""
|
|
29
|
+
);
|
|
30
|
+
const pubkey = String(evmAccount.pubkey || genResponse.pubkey || "");
|
|
31
|
+
const solMaterial = genResponse.solana || {};
|
|
32
|
+
let btcAddress = genResponse.btcAddress || "";
|
|
33
|
+
let trxAddress = genResponse.trxAddress || "";
|
|
34
|
+
let xrpAddress = genResponse.xrpAddress || "";
|
|
35
|
+
if ((!btcAddress || !trxAddress || !xrpAddress) && pubkey) {
|
|
36
|
+
try {
|
|
37
|
+
const api = getTalkenApiClient();
|
|
38
|
+
if (api) {
|
|
39
|
+
const addrResponse = await api.wallet.getAddressForChain("all");
|
|
40
|
+
if (!btcAddress)
|
|
41
|
+
btcAddress = addrResponse?.btc || addrResponse?.btcAddress || "";
|
|
42
|
+
if (!trxAddress)
|
|
43
|
+
trxAddress = addrResponse?.trx || addrResponse?.trxAddress || "";
|
|
44
|
+
if (!xrpAddress)
|
|
45
|
+
xrpAddress = addrResponse?.xrp || addrResponse?.xrpAddress || "";
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
logger.warn("Failed to derive BTC/TRX/XRP addresses:", err);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const pvencstr = String(evmAccount.pvencstr || "");
|
|
52
|
+
const edp = String(evmAccount.encryptDevicePassword || "");
|
|
53
|
+
if (uid && wid && sid && pvencstr && edp) {
|
|
54
|
+
getCredentialManager().setEvmSigningCredentials({
|
|
55
|
+
uid,
|
|
56
|
+
wid,
|
|
57
|
+
sid,
|
|
58
|
+
pvencstr,
|
|
59
|
+
encryptDevicePassword: edp
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const evmWallet = {
|
|
63
|
+
uid,
|
|
64
|
+
sessionId: sid,
|
|
65
|
+
keyId: wid,
|
|
66
|
+
encryptedShare: pvencstr,
|
|
67
|
+
secretStore: edp,
|
|
68
|
+
address: genResponse.evmAddress || sid,
|
|
69
|
+
chainId: getEvmNetwork(),
|
|
70
|
+
sid,
|
|
71
|
+
type: "evm",
|
|
72
|
+
email,
|
|
73
|
+
pubkey
|
|
74
|
+
};
|
|
75
|
+
const solanaWallet = {
|
|
76
|
+
uid,
|
|
77
|
+
sessionId: String(solMaterial.shareId || ""),
|
|
78
|
+
keyId: String(solMaterial.keyId || ""),
|
|
79
|
+
encryptedShare: String(solMaterial.encryptedShare || ""),
|
|
80
|
+
secretStore: String(solMaterial.secretStore || ""),
|
|
81
|
+
shareId: String(solMaterial.shareId || ""),
|
|
82
|
+
publicKey: String(solMaterial.publicKey || ""),
|
|
83
|
+
address: genResponse.solAddress || solMaterial.address || "",
|
|
84
|
+
network: getSolanaNetwork()
|
|
85
|
+
};
|
|
86
|
+
const bitcoinWallet = {
|
|
87
|
+
uid,
|
|
88
|
+
sessionId: sid,
|
|
89
|
+
keyId: wid,
|
|
90
|
+
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
91
|
+
shareId: sid,
|
|
92
|
+
publicKey: pubkey,
|
|
93
|
+
address: btcAddress,
|
|
94
|
+
addressType: "bech32",
|
|
95
|
+
network: getBitcoinNetwork()
|
|
96
|
+
};
|
|
97
|
+
const tronWallet = {
|
|
98
|
+
uid,
|
|
99
|
+
sessionId: sid,
|
|
100
|
+
keyId: wid,
|
|
101
|
+
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
102
|
+
shareId: sid,
|
|
103
|
+
publicKey: pubkey,
|
|
104
|
+
address: trxAddress,
|
|
105
|
+
network: getTronNetwork()
|
|
106
|
+
};
|
|
107
|
+
const xrplWallet = {
|
|
108
|
+
uid,
|
|
109
|
+
sessionId: sid,
|
|
110
|
+
keyId: wid,
|
|
111
|
+
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
112
|
+
shareId: sid,
|
|
113
|
+
publicKey: pubkey,
|
|
114
|
+
address: xrpAddress,
|
|
115
|
+
network: getXrplNetwork()
|
|
116
|
+
};
|
|
117
|
+
return { evmWallet, solanaWallet, bitcoinWallet, tronWallet, xrplWallet };
|
|
118
|
+
}
|
|
119
|
+
async function generateMpcWallets(hashedPin, email) {
|
|
120
|
+
const api = getTalkenApiClient();
|
|
121
|
+
if (!api) {
|
|
122
|
+
throw new AbcError(
|
|
123
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
124
|
+
"TalkenApiClient not initialized"
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const genResponse = await api.wallet.generate(hashedPin, email);
|
|
129
|
+
const infoResponse = await api.wallet.getInfo().catch(() => ({}));
|
|
130
|
+
return await mapApiResponseToWallets(
|
|
131
|
+
genResponse,
|
|
132
|
+
infoResponse,
|
|
133
|
+
email || ""
|
|
134
|
+
);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
throw new AbcError(
|
|
137
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
138
|
+
`Failed to generate MPC wallets: ${error.message}`,
|
|
139
|
+
{ originalError: error }
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function recoverMpcWallets(hashedPin, email) {
|
|
144
|
+
const api = getTalkenApiClient();
|
|
145
|
+
if (!api) {
|
|
146
|
+
throw new AbcError(
|
|
147
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
148
|
+
"TalkenApiClient not initialized"
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const genResponse = await api.wallet.recover(hashedPin, email);
|
|
153
|
+
const infoResponse = await api.wallet.getInfo().catch(() => ({}));
|
|
154
|
+
return await mapApiResponseToWallets(
|
|
155
|
+
genResponse,
|
|
156
|
+
infoResponse,
|
|
157
|
+
email || ""
|
|
158
|
+
);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw new AbcError(
|
|
161
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
162
|
+
`Failed to recover MPC wallets: ${error.message}`,
|
|
163
|
+
{ originalError: error }
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function validateMpcWallets(result) {
|
|
168
|
+
const errors = [];
|
|
169
|
+
if (!result.evmWallet) {
|
|
170
|
+
errors.push("EVM wallet is missing");
|
|
171
|
+
} else {
|
|
172
|
+
if (!result.evmWallet.address || !result.evmWallet.address.startsWith("0x")) {
|
|
173
|
+
errors.push("Invalid EVM wallet address");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!result.solanaWallet) {
|
|
177
|
+
errors.push("Solana wallet is missing");
|
|
178
|
+
} else {
|
|
179
|
+
if (!result.solanaWallet.address) {
|
|
180
|
+
errors.push("Invalid Solana wallet address");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (!result.bitcoinWallet) {
|
|
184
|
+
errors.push("Bitcoin wallet is missing");
|
|
185
|
+
} else {
|
|
186
|
+
if (!result.bitcoinWallet.address) {
|
|
187
|
+
errors.push("Invalid Bitcoin wallet address");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!result.tronWallet) {
|
|
191
|
+
errors.push("TRON wallet is missing");
|
|
192
|
+
} else {
|
|
193
|
+
if (!result.tronWallet.address) {
|
|
194
|
+
errors.push("Invalid TRON wallet address");
|
|
195
|
+
} else if (!result.tronWallet.address.startsWith("T")) {
|
|
196
|
+
errors.push("Invalid TRON address format (expected T prefix)");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!result.xrplWallet) {
|
|
200
|
+
errors.push("XRPL wallet is missing");
|
|
201
|
+
} else {
|
|
202
|
+
if (!result.xrplWallet.address) {
|
|
203
|
+
errors.push("Invalid XRPL wallet address");
|
|
204
|
+
} else if (!result.xrplWallet.address.startsWith("r")) {
|
|
205
|
+
errors.push("Invalid XRPL address format (expected r prefix)");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
valid: errors.length === 0,
|
|
210
|
+
errors
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
generateMpcWallets,
|
|
216
|
+
recoverMpcWallets,
|
|
217
|
+
validateMpcWallets
|
|
218
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/wallets/walletConnectors/abcWallet/types/config.types.ts
|
|
4
|
+
var AbcStorageKey = /* @__PURE__ */ ((AbcStorageKey2) => {
|
|
5
|
+
AbcStorageKey2["USER"] = "user";
|
|
6
|
+
AbcStorageKey2["WALLET"] = "wallet";
|
|
7
|
+
AbcStorageKey2["SOLANA_WALLET"] = "solana_wallet";
|
|
8
|
+
AbcStorageKey2["BITCOIN_WALLET"] = "bitcoin_wallet";
|
|
9
|
+
AbcStorageKey2["TRON_WALLET"] = "tron_wallet";
|
|
10
|
+
AbcStorageKey2["XRPL_WALLET"] = "xrpl_wallet";
|
|
11
|
+
AbcStorageKey2["ACCESS_TOKEN"] = "access_token";
|
|
12
|
+
AbcStorageKey2["REFRESH_TOKEN"] = "refresh_token";
|
|
13
|
+
AbcStorageKey2["EXPIRES_AT"] = "expires_at";
|
|
14
|
+
AbcStorageKey2["AUTH_STATE"] = "auth_state";
|
|
15
|
+
return AbcStorageKey2;
|
|
16
|
+
})(AbcStorageKey || {});
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
AbcStorageKey
|
|
20
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
abcConnector
|
|
4
|
+
} from "./chunk-TM6YD43A.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveTalkenApiUrl
|
|
7
|
+
} from "./chunk-GFWUFYT2.js";
|
|
8
|
+
import {
|
|
9
|
+
createTalkenApiClient
|
|
10
|
+
} from "./chunk-QODJUJ3A.js";
|
|
11
|
+
import {
|
|
12
|
+
ABC_WALLET_METADATA,
|
|
13
|
+
loadTgAccessKey
|
|
14
|
+
} from "./chunk-3Z5DO42M.js";
|
|
15
|
+
|
|
16
|
+
// src/wallets/walletConnectors/abcWallet/abcWallet.ts
|
|
17
|
+
import { setTalkenApiClient } from "@talken/talkenkit";
|
|
18
|
+
var abcWallet = (specificOptions) => ({ projectId }) => {
|
|
19
|
+
const talkenApiUrl = resolveTalkenApiUrl(specificOptions?.talkenApiUrl);
|
|
20
|
+
const talkenApi = createTalkenApiClient({
|
|
21
|
+
baseUrl: talkenApiUrl,
|
|
22
|
+
debug: specificOptions?.environment === "development"
|
|
23
|
+
});
|
|
24
|
+
setTalkenApiClient(talkenApi);
|
|
25
|
+
const accessKey = specificOptions?.accessKey || loadTgAccessKey() || null;
|
|
26
|
+
const config = {
|
|
27
|
+
talkenApiUrl,
|
|
28
|
+
apiKey: specificOptions?.apiKey,
|
|
29
|
+
plain: specificOptions?.plain || "",
|
|
30
|
+
// Deprecated - not used (secure.ts uses random generation)
|
|
31
|
+
environment: specificOptions?.environment || "development",
|
|
32
|
+
defaultChainId: specificOptions?.defaultChainId,
|
|
33
|
+
defaultSolanaNetwork: specificOptions?.defaultSolanaNetwork,
|
|
34
|
+
defaultBitcoinNetwork: specificOptions?.defaultBitcoinNetwork,
|
|
35
|
+
projectId,
|
|
36
|
+
...accessKey && { accessKey }
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
id: ABC_WALLET_METADATA.id,
|
|
40
|
+
name: ABC_WALLET_METADATA.name,
|
|
41
|
+
rdns: ABC_WALLET_METADATA.rdns,
|
|
42
|
+
iconUrl: async () => (await import("./abcWallet-4PXRQO5T.js")).default,
|
|
43
|
+
iconBackground: ABC_WALLET_METADATA.iconBackground,
|
|
44
|
+
// Embedded wallet - no installation required
|
|
45
|
+
installed: void 0,
|
|
46
|
+
// No download URLs for embedded wallet
|
|
47
|
+
downloadUrls: void 0,
|
|
48
|
+
// Create connector - wrapper function required by Wallet type
|
|
49
|
+
// If accessKey exists, abcConnector will use AbcAccessKeyProvider internally
|
|
50
|
+
createConnector: (_walletDetails) => abcConnector({ config }),
|
|
51
|
+
// Embedded wallet always available
|
|
52
|
+
hidden: () => false
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
abcWallet
|
|
58
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
TALKEN_API_ENDPOINTS
|
|
4
|
+
} from "./chunk-3Z5DO42M.js";
|
|
5
|
+
|
|
6
|
+
// src/wallets/walletConnectors/abcWallet/api/ConfigApi.ts
|
|
7
|
+
import { getTalkenApiClient } from "@talken/talkenkit";
|
|
8
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
var toStatusCode = (status) => {
|
|
10
|
+
if (typeof status === "number")
|
|
11
|
+
return status;
|
|
12
|
+
if (typeof status === "string") {
|
|
13
|
+
const normalized = status.trim().toLowerCase();
|
|
14
|
+
if (normalized === "success")
|
|
15
|
+
return 1;
|
|
16
|
+
if (normalized === "reverted" || normalized === "failed")
|
|
17
|
+
return 0;
|
|
18
|
+
const parsed = Number(status);
|
|
19
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
var ConfigApi = class {
|
|
24
|
+
async getTxStatus(chainKey, txHash) {
|
|
25
|
+
const api = getTalkenApiClient();
|
|
26
|
+
if (!api)
|
|
27
|
+
throw new Error("TalkenApiClient not initialized");
|
|
28
|
+
return api.get(
|
|
29
|
+
`${TALKEN_API_ENDPOINTS.CONFIG_TX_STATUS}/${encodeURIComponent(chainKey)}/${encodeURIComponent(txHash)}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
async waitForTxStatus(chainKey, txHash, options = {}) {
|
|
33
|
+
const { timeoutMs = 3e5, pollIntervalMs = 3e3 } = options;
|
|
34
|
+
const deadline = Date.now() + timeoutMs;
|
|
35
|
+
while (Date.now() < deadline) {
|
|
36
|
+
const status = await this.getTxStatus(chainKey, txHash);
|
|
37
|
+
if (status.found) {
|
|
38
|
+
const code = toStatusCode(status.status);
|
|
39
|
+
if (code !== null && code !== 1) {
|
|
40
|
+
throw new Error(status.message || "Transaction reverted on-chain");
|
|
41
|
+
}
|
|
42
|
+
return status;
|
|
43
|
+
}
|
|
44
|
+
await sleep(pollIntervalMs);
|
|
45
|
+
}
|
|
46
|
+
throw new Error("Transaction confirmation timed out");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
ConfigApi
|
|
52
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getBitcoinNetwork,
|
|
4
|
+
getEvmNetwork,
|
|
5
|
+
getSolanaNetwork,
|
|
6
|
+
getTronNetwork,
|
|
7
|
+
getXrplNetwork
|
|
8
|
+
} from "./chunk-X3DT5G3F.js";
|
|
9
|
+
import {
|
|
10
|
+
createLogger
|
|
11
|
+
} from "./chunk-762I67R6.js";
|
|
12
|
+
import {
|
|
13
|
+
getCredentialManager
|
|
14
|
+
} from "./chunk-YNE2UX2Z.js";
|
|
15
|
+
import {
|
|
16
|
+
AbcError
|
|
17
|
+
} from "./chunk-BUAWEYGV.js";
|
|
18
|
+
|
|
19
|
+
// src/wallets/walletConnectors/abcWallet/walletGeneration.ts
|
|
20
|
+
import { getTalkenApiClient } from "@talken/talkenkit";
|
|
21
|
+
var logger = createLogger("WalletGeneration");
|
|
22
|
+
async function mapApiResponseToWallets(genResponse, infoResponse, email) {
|
|
23
|
+
const accounts = infoResponse?.accounts || [];
|
|
24
|
+
const evmAccount = accounts[0] || infoResponse || {};
|
|
25
|
+
const uid = String(genResponse.uid || evmAccount.uid || "");
|
|
26
|
+
const wid = String(genResponse.wid || evmAccount.wid || "");
|
|
27
|
+
const sid = String(
|
|
28
|
+
evmAccount.sid || evmAccount.ethAddress || genResponse.evmAddress || ""
|
|
29
|
+
);
|
|
30
|
+
const pubkey = String(evmAccount.pubkey || genResponse.pubkey || "");
|
|
31
|
+
const solMaterial = genResponse.solana || {};
|
|
32
|
+
let btcAddress = genResponse.btcAddress || "";
|
|
33
|
+
let trxAddress = genResponse.trxAddress || "";
|
|
34
|
+
let xrpAddress = genResponse.xrpAddress || "";
|
|
35
|
+
if ((!btcAddress || !trxAddress || !xrpAddress) && pubkey) {
|
|
36
|
+
try {
|
|
37
|
+
const api = getTalkenApiClient();
|
|
38
|
+
if (api) {
|
|
39
|
+
const addrResponse = await api.wallet.getAddressForChain("all");
|
|
40
|
+
if (!btcAddress)
|
|
41
|
+
btcAddress = addrResponse?.btc || addrResponse?.btcAddress || "";
|
|
42
|
+
if (!trxAddress)
|
|
43
|
+
trxAddress = addrResponse?.trx || addrResponse?.trxAddress || "";
|
|
44
|
+
if (!xrpAddress)
|
|
45
|
+
xrpAddress = addrResponse?.xrp || addrResponse?.xrpAddress || "";
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
logger.warn("Failed to derive BTC/TRX/XRP addresses:", err);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const pvencstr = String(evmAccount.pvencstr || "");
|
|
52
|
+
const edp = String(evmAccount.encryptDevicePassword || "");
|
|
53
|
+
if (uid && wid && sid && pvencstr && edp) {
|
|
54
|
+
getCredentialManager().setEvmSigningCredentials({
|
|
55
|
+
uid,
|
|
56
|
+
wid,
|
|
57
|
+
sid,
|
|
58
|
+
pvencstr,
|
|
59
|
+
encryptDevicePassword: edp
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const evmWallet = {
|
|
63
|
+
uid,
|
|
64
|
+
sessionId: sid,
|
|
65
|
+
keyId: wid,
|
|
66
|
+
encryptedShare: pvencstr,
|
|
67
|
+
secretStore: edp,
|
|
68
|
+
address: genResponse.evmAddress || sid,
|
|
69
|
+
chainId: getEvmNetwork(),
|
|
70
|
+
sid,
|
|
71
|
+
type: "evm",
|
|
72
|
+
email,
|
|
73
|
+
pubkey
|
|
74
|
+
};
|
|
75
|
+
const solanaWallet = {
|
|
76
|
+
uid,
|
|
77
|
+
sessionId: String(solMaterial.shareId || ""),
|
|
78
|
+
keyId: String(solMaterial.keyId || ""),
|
|
79
|
+
encryptedShare: String(solMaterial.encryptedShare || ""),
|
|
80
|
+
secretStore: String(solMaterial.secretStore || ""),
|
|
81
|
+
shareId: String(solMaterial.shareId || ""),
|
|
82
|
+
publicKey: String(solMaterial.publicKey || ""),
|
|
83
|
+
address: genResponse.solAddress || solMaterial.address || "",
|
|
84
|
+
network: getSolanaNetwork()
|
|
85
|
+
};
|
|
86
|
+
const bitcoinWallet = {
|
|
87
|
+
uid,
|
|
88
|
+
sessionId: sid,
|
|
89
|
+
keyId: wid,
|
|
90
|
+
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
91
|
+
shareId: sid,
|
|
92
|
+
publicKey: pubkey,
|
|
93
|
+
address: btcAddress,
|
|
94
|
+
addressType: "bech32",
|
|
95
|
+
network: getBitcoinNetwork()
|
|
96
|
+
};
|
|
97
|
+
const tronWallet = {
|
|
98
|
+
uid,
|
|
99
|
+
sessionId: sid,
|
|
100
|
+
keyId: wid,
|
|
101
|
+
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
102
|
+
shareId: sid,
|
|
103
|
+
publicKey: pubkey,
|
|
104
|
+
address: trxAddress,
|
|
105
|
+
network: getTronNetwork()
|
|
106
|
+
};
|
|
107
|
+
const xrplWallet = {
|
|
108
|
+
uid,
|
|
109
|
+
sessionId: sid,
|
|
110
|
+
keyId: wid,
|
|
111
|
+
encryptedShare: String(evmAccount.pvencstr || ""),
|
|
112
|
+
shareId: sid,
|
|
113
|
+
publicKey: pubkey,
|
|
114
|
+
address: xrpAddress,
|
|
115
|
+
network: getXrplNetwork()
|
|
116
|
+
};
|
|
117
|
+
return { evmWallet, solanaWallet, bitcoinWallet, tronWallet, xrplWallet };
|
|
118
|
+
}
|
|
119
|
+
async function generateMpcWallets(hashedPin, email) {
|
|
120
|
+
const api = getTalkenApiClient();
|
|
121
|
+
if (!api) {
|
|
122
|
+
throw new AbcError(
|
|
123
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
124
|
+
"TalkenApiClient not initialized"
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const genResponse = await api.wallet.generate(hashedPin, email);
|
|
129
|
+
const infoResponse = await api.wallet.getInfo().catch(() => ({}));
|
|
130
|
+
return await mapApiResponseToWallets(
|
|
131
|
+
genResponse,
|
|
132
|
+
infoResponse,
|
|
133
|
+
email || ""
|
|
134
|
+
);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
throw new AbcError(
|
|
137
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
138
|
+
`Failed to generate MPC wallets: ${error.message}`,
|
|
139
|
+
{ originalError: error }
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function recoverMpcWallets(hashedPin, email) {
|
|
144
|
+
const api = getTalkenApiClient();
|
|
145
|
+
if (!api) {
|
|
146
|
+
throw new AbcError(
|
|
147
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
148
|
+
"TalkenApiClient not initialized"
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const genResponse = await api.wallet.recover(hashedPin, email);
|
|
153
|
+
const infoResponse = await api.wallet.getInfo().catch(() => ({}));
|
|
154
|
+
return await mapApiResponseToWallets(
|
|
155
|
+
genResponse,
|
|
156
|
+
infoResponse,
|
|
157
|
+
email || ""
|
|
158
|
+
);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw new AbcError(
|
|
161
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
162
|
+
`Failed to recover MPC wallets: ${error.message}`,
|
|
163
|
+
{ originalError: error }
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function validateMpcWallets(result) {
|
|
168
|
+
const errors = [];
|
|
169
|
+
if (!result.evmWallet) {
|
|
170
|
+
errors.push("EVM wallet is missing");
|
|
171
|
+
} else {
|
|
172
|
+
if (!result.evmWallet.address || !result.evmWallet.address.startsWith("0x")) {
|
|
173
|
+
errors.push("Invalid EVM wallet address");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!result.solanaWallet) {
|
|
177
|
+
errors.push("Solana wallet is missing");
|
|
178
|
+
} else {
|
|
179
|
+
if (!result.solanaWallet.address) {
|
|
180
|
+
errors.push("Invalid Solana wallet address");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (!result.bitcoinWallet) {
|
|
184
|
+
errors.push("Bitcoin wallet is missing");
|
|
185
|
+
} else {
|
|
186
|
+
if (!result.bitcoinWallet.address) {
|
|
187
|
+
errors.push("Invalid Bitcoin wallet address");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!result.tronWallet) {
|
|
191
|
+
errors.push("TRON wallet is missing");
|
|
192
|
+
} else {
|
|
193
|
+
if (!result.tronWallet.address) {
|
|
194
|
+
errors.push("Invalid TRON wallet address");
|
|
195
|
+
} else if (!result.tronWallet.address.startsWith("T")) {
|
|
196
|
+
errors.push("Invalid TRON address format (expected T prefix)");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!result.xrplWallet) {
|
|
200
|
+
errors.push("XRPL wallet is missing");
|
|
201
|
+
} else {
|
|
202
|
+
if (!result.xrplWallet.address) {
|
|
203
|
+
errors.push("Invalid XRPL wallet address");
|
|
204
|
+
} else if (!result.xrplWallet.address.startsWith("r")) {
|
|
205
|
+
errors.push("Invalid XRPL address format (expected r prefix)");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
valid: errors.length === 0,
|
|
210
|
+
errors
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
generateMpcWallets,
|
|
216
|
+
recoverMpcWallets,
|
|
217
|
+
validateMpcWallets
|
|
218
|
+
};
|