@talken/talkenkit 2.4.21 → 2.4.22
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/LICENSE +9 -0
- package/dist/abcWallet-4RS3B4ZG.js +188 -0
- package/dist/abcWallet-EBOW2RJB.js +188 -0
- package/dist/abcWallet-RS4EOJ4I.js +188 -0
- package/dist/abcWallet-SNEZVK7V.js +188 -0
- package/dist/abcWallet-TC7M2JYX.js +188 -0
- package/dist/abcWallet-VZMW2DR3.js +188 -0
- package/dist/abcWallet-XJ3WSUVI.js +188 -0
- package/dist/abcWallet-XNCBZAIQ.js +188 -0
- package/dist/chunk-6FLQAAC4.js +7213 -0
- package/dist/chunk-7GIIMIPN.js +7213 -0
- package/dist/chunk-IBFA37SC.js +7228 -0
- package/dist/chunk-O5ZOC4NJ.js +7215 -0
- package/dist/chunk-OPOAKGEX.js +7216 -0
- package/dist/chunk-OTIHVCVR.js +7213 -0
- package/dist/chunk-P77BVZZF.js +7369 -0
- package/dist/chunk-RFLXXSQH.js +7139 -0
- package/dist/components/ConfirmationModal/NonEvmConfirmationModal.css.d.ts +11 -0
- package/dist/components/ConfirmationModal/NonEvmSignConfirmationModal.d.ts +9 -0
- package/dist/components/ConfirmationModal/NonEvmTransferConfirmationModal.d.ts +9 -0
- package/dist/components/ConfirmationModal/SignConfirmationModal.css.d.ts +1 -19
- package/dist/components/ConfirmationModal/TransactionConfirmationModal.css.d.ts +1 -20
- package/dist/components/ConfirmationModal/commonStyles.css.d.ts +19 -0
- package/dist/components/ConfirmationModal/index.d.ts +2 -0
- package/dist/components/ConfirmationModal/utils.d.ts +2 -1
- package/dist/hooks/useWalletCapabilities.d.ts +2 -0
- package/dist/index.css +227 -307
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2004 -1064
- package/dist/providers/SignConfirmationProvider/NonEvmConfirmationContext.d.ts +6 -0
- package/dist/providers/SignConfirmationProvider/index.d.ts +2 -1
- package/dist/providers/SignConfirmationProvider/requestParsers.d.ts +6 -1
- package/dist/providers/SignConfirmationProvider/types.d.ts +35 -1
- package/dist/wallets/capabilities/detectCapabilities.d.ts +7 -0
- package/dist/wallets/capabilities/requestWalletAction.d.ts +8 -0
- package/dist/wallets/capabilities/types.d.ts +50 -0
- package/dist/wallets/walletConnectors/abcWallet/abcApi.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.d.ts +10 -0
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +5 -5
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +9 -0
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.d.ts +10 -0
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.d.ts +16 -0
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +115 -33
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.d.ts +16 -0
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +7 -7
- package/dist/wallets/walletConnectors/abcWallet/api/AuthApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/BaseApiClient.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/BitcoinApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/GasApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/SolanaApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +9 -4
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/TransactionApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/TronApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/WalletApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +13 -13
- package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +5 -4
- package/dist/wallets/walletConnectors/abcWallet/constants.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/index.js +21 -21
- package/dist/wallets/walletConnectors/abcWallet/types.d.ts +31 -1
- package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
- 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-2IZBLAHI.js +52 -0
- package/dist/wallets/walletConnectors/chunk-32IJ3ILH.js +71 -0
- package/dist/wallets/walletConnectors/chunk-3AX66UHT.js +479 -0
- package/dist/wallets/walletConnectors/chunk-3BVPV64G.js +36 -0
- package/dist/wallets/walletConnectors/chunk-3DGFHWI3.js +302 -0
- package/dist/wallets/walletConnectors/chunk-4FKUVQCM.js +655 -0
- package/dist/wallets/walletConnectors/chunk-56SF4VRC.js +640 -0
- package/dist/wallets/walletConnectors/chunk-5KOE7NJW.js +52 -0
- package/dist/wallets/walletConnectors/chunk-6CVXZ3ZW.js +771 -0
- package/dist/wallets/walletConnectors/chunk-6GCWEPU7.js +643 -0
- package/dist/wallets/walletConnectors/chunk-6YFP3Q2I.js +118 -0
- package/dist/wallets/walletConnectors/chunk-7EEPPULA.js +118 -0
- package/dist/wallets/walletConnectors/chunk-7QL42XTB.js +302 -0
- package/dist/wallets/walletConnectors/chunk-A7ZSPSFX.js +577 -0
- package/dist/wallets/walletConnectors/chunk-AI3CT254.js +302 -0
- package/dist/wallets/walletConnectors/chunk-AMNVH7CZ.js +151 -0
- package/dist/wallets/walletConnectors/chunk-AOREXGRM.js +350 -0
- package/dist/wallets/walletConnectors/chunk-BLO7E54F.js +302 -0
- package/dist/wallets/walletConnectors/chunk-BNRH5PYS.js +52 -0
- package/dist/wallets/walletConnectors/chunk-BOV5FXU6.js +151 -0
- package/dist/wallets/walletConnectors/chunk-BR25RFNF.js +260 -0
- package/dist/wallets/walletConnectors/chunk-BXQ2UWJ3.js +91 -0
- package/dist/wallets/walletConnectors/chunk-CAMPW7O2.js +874 -0
- package/dist/wallets/walletConnectors/chunk-CLMFCNP7.js +52 -0
- package/dist/wallets/walletConnectors/chunk-DSZOE65L.js +107 -0
- package/dist/wallets/walletConnectors/chunk-DU6RCLWT.js +272 -0
- package/dist/wallets/walletConnectors/chunk-ENN6UGGA.js +421 -0
- package/dist/wallets/walletConnectors/chunk-EXWDLN5V.js +204 -0
- package/dist/wallets/walletConnectors/chunk-FFU26Y5Y.js +272 -0
- package/dist/wallets/walletConnectors/chunk-FGS2WHVA.js +118 -0
- package/dist/wallets/walletConnectors/chunk-FJJ3QI4R.js +91 -0
- package/dist/wallets/walletConnectors/chunk-FS2OOQYF.js +204 -0
- package/dist/wallets/walletConnectors/chunk-G5X3COSW.js +205 -0
- package/dist/wallets/walletConnectors/chunk-H53R4SFZ.js +204 -0
- package/dist/wallets/walletConnectors/chunk-J4QGDATF.js +71 -0
- package/dist/wallets/walletConnectors/chunk-JIJNCMJR.js +874 -0
- package/dist/wallets/walletConnectors/chunk-JSGZYU4A.js +52 -0
- package/dist/wallets/walletConnectors/chunk-JVT7R2GZ.js +771 -0
- package/dist/wallets/walletConnectors/chunk-K3JNN5UK.js +71 -0
- package/dist/wallets/walletConnectors/chunk-KBHPY3NA.js +302 -0
- package/dist/wallets/walletConnectors/chunk-KEX6WS23.js +640 -0
- package/dist/wallets/walletConnectors/chunk-KHYKVVR7.js +52 -0
- package/dist/wallets/walletConnectors/chunk-LOL7ZZ3S.js +302 -0
- package/dist/wallets/walletConnectors/chunk-LOSXI36Y.js +479 -0
- package/dist/wallets/walletConnectors/chunk-M2U5QGM7.js +260 -0
- package/dist/wallets/walletConnectors/chunk-M73AWLIV.js +107 -0
- package/dist/wallets/walletConnectors/chunk-MAUC46AE.js +302 -0
- package/dist/wallets/walletConnectors/chunk-MBRXYEQC.js +272 -0
- package/dist/wallets/walletConnectors/chunk-MDDD4LG2.js +874 -0
- package/dist/wallets/walletConnectors/chunk-MMR2QAEU.js +642 -0
- package/dist/wallets/walletConnectors/chunk-MNZZRFUC.js +302 -0
- package/dist/wallets/walletConnectors/chunk-OIRY24PH.js +302 -0
- package/dist/wallets/walletConnectors/chunk-ORBX4JE2.js +52 -0
- package/dist/wallets/walletConnectors/chunk-OXJFFDW7.js +761 -0
- package/dist/wallets/walletConnectors/chunk-QD3PPWTN.js +272 -0
- package/dist/wallets/walletConnectors/chunk-RCIABMG5.js +259 -0
- package/dist/wallets/walletConnectors/chunk-RHC4SVLB.js +71 -0
- package/dist/wallets/walletConnectors/chunk-S2CB4KFC.js +71 -0
- package/dist/wallets/walletConnectors/chunk-S6HZD4XZ.js +302 -0
- package/dist/wallets/walletConnectors/chunk-S72LCNVX.js +272 -0
- package/dist/wallets/walletConnectors/chunk-SCWE5EEX.js +91 -0
- package/dist/wallets/walletConnectors/chunk-TKEL4D4E.js +151 -0
- package/dist/wallets/walletConnectors/chunk-TKJEMEBZ.js +71 -0
- package/dist/wallets/walletConnectors/chunk-TZ44ZREA.js +302 -0
- package/dist/wallets/walletConnectors/chunk-UGQSI3US.js +547 -0
- package/dist/wallets/walletConnectors/chunk-UU4JYY3C.js +205 -0
- package/dist/wallets/walletConnectors/chunk-V5P5BL6Z.js +302 -0
- package/dist/wallets/walletConnectors/chunk-VH6DIRPF.js +71 -0
- package/dist/wallets/walletConnectors/chunk-VPNZAMW5.js +205 -0
- package/dist/wallets/walletConnectors/chunk-W6QN6QXO.js +52 -0
- package/dist/wallets/walletConnectors/chunk-WDULICVN.js +302 -0
- package/dist/wallets/walletConnectors/chunk-WGGHGODM.js +272 -0
- package/dist/wallets/walletConnectors/chunk-XUCMTLM3.js +52 -0
- package/dist/wallets/walletConnectors/chunk-Y5WAX6WO.js +52 -0
- package/dist/wallets/walletConnectors/chunk-Y62PFBWE.js +640 -0
- package/dist/wallets/walletConnectors/chunk-Z6ABK6G6.js +107 -0
- package/dist/wallets/walletConnectors/chunk-ZCA5QSIM.js +71 -0
- package/dist/wallets/walletConnectors/chunk-ZJDZJW55.js +479 -0
- package/dist/wallets/walletConnectors/chunk-ZOF7ZDGU.js +52 -0
- package/dist/wallets/walletConnectors/chunk-ZUU57RHO.js +36 -0
- package/dist/wallets/walletConnectors/chunk-ZWFGRREM.js +36 -0
- package/dist/wallets/walletConnectors/chunk-ZY5BCHP2.js +302 -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 +91 -91
- 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 +11 -12
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
BaseApiClient
|
|
4
|
+
} from "./chunk-MBRXYEQC.js";
|
|
5
|
+
import {
|
|
6
|
+
createAbcError
|
|
7
|
+
} from "./chunk-LOSXI36Y.js";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_HEADERS
|
|
10
|
+
} from "./chunk-BR25RFNF.js";
|
|
11
|
+
|
|
12
|
+
// src/wallets/walletConnectors/abcWallet/api/BitcoinApi.ts
|
|
13
|
+
var BitcoinApi = class extends BaseApiClient {
|
|
14
|
+
/**
|
|
15
|
+
* Generate Bitcoin wallet
|
|
16
|
+
* Uses V3 API with secp256k1 curve (same as EVM but compressed public key)
|
|
17
|
+
*
|
|
18
|
+
* @param pin - Hashed PIN (SHA-256)
|
|
19
|
+
* @param network - Bitcoin network (mainnet or testnet)
|
|
20
|
+
* @param addressType - Bitcoin address type (bech32 recommended)
|
|
21
|
+
* @returns Bitcoin wallet information
|
|
22
|
+
*/
|
|
23
|
+
async generateBitcoinWallet(pin, network = "bitcoin", addressType = "bech32") {
|
|
24
|
+
console.log("[BitcoinApi] Generating Bitcoin wallet...", {
|
|
25
|
+
network,
|
|
26
|
+
addressType
|
|
27
|
+
});
|
|
28
|
+
const response = await this.request("/v3/wallet/generate", {
|
|
29
|
+
method: "POST",
|
|
30
|
+
contentType: "json",
|
|
31
|
+
body: {
|
|
32
|
+
curve: "secp256k1",
|
|
33
|
+
// Same as EVM but compressed public key
|
|
34
|
+
password: pin,
|
|
35
|
+
network
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (response.status !== "success" || !response.result) {
|
|
39
|
+
console.error("[BitcoinApi] Generation failed:", response);
|
|
40
|
+
throw createAbcError(
|
|
41
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
42
|
+
"Failed to generate Bitcoin wallet",
|
|
43
|
+
response
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
const result = response.result;
|
|
47
|
+
const addressResult = await this.getBitcoinAddress(
|
|
48
|
+
result.public_key,
|
|
49
|
+
network,
|
|
50
|
+
addressType
|
|
51
|
+
);
|
|
52
|
+
return {
|
|
53
|
+
uid: result.uid || "",
|
|
54
|
+
sessionId: result.share_id,
|
|
55
|
+
shareId: result.share_id,
|
|
56
|
+
publicKey: result.public_key,
|
|
57
|
+
// Compressed (33 bytes, 0x02 or 0x03 prefix)
|
|
58
|
+
address: addressResult,
|
|
59
|
+
addressType,
|
|
60
|
+
keyId: result.key_id || result.share_id,
|
|
61
|
+
encryptedShare: result.encrypted_share || "",
|
|
62
|
+
network
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Recover Bitcoin wallet
|
|
67
|
+
* Uses V3 API wallet recovery endpoint
|
|
68
|
+
*
|
|
69
|
+
* @param pin - Hashed PIN (SHA-256)
|
|
70
|
+
* @param network - Bitcoin network
|
|
71
|
+
* @param addressType - Bitcoin address type
|
|
72
|
+
* @returns Recovered Bitcoin wallet information
|
|
73
|
+
*/
|
|
74
|
+
async recoverBitcoinWallet(pin, network = "bitcoin", addressType = "bech32") {
|
|
75
|
+
console.log("[BitcoinApi] Recovering Bitcoin wallet...", {
|
|
76
|
+
network,
|
|
77
|
+
addressType
|
|
78
|
+
});
|
|
79
|
+
const response = await this.request("/v3/wallet/recover", {
|
|
80
|
+
method: "POST",
|
|
81
|
+
contentType: "json",
|
|
82
|
+
body: {
|
|
83
|
+
curve: "secp256k1",
|
|
84
|
+
password: pin,
|
|
85
|
+
network
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (response.status !== "success" || !response.result) {
|
|
89
|
+
console.error("[BitcoinApi] Recovery failed:", response);
|
|
90
|
+
throw createAbcError(
|
|
91
|
+
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
92
|
+
"Failed to recover Bitcoin wallet",
|
|
93
|
+
response
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const result = response.result;
|
|
97
|
+
const addressResult = await this.getBitcoinAddress(
|
|
98
|
+
result.public_key,
|
|
99
|
+
network,
|
|
100
|
+
addressType
|
|
101
|
+
);
|
|
102
|
+
return {
|
|
103
|
+
uid: result.uid || "",
|
|
104
|
+
sessionId: result.share_id,
|
|
105
|
+
shareId: result.share_id,
|
|
106
|
+
publicKey: result.public_key,
|
|
107
|
+
address: addressResult,
|
|
108
|
+
addressType,
|
|
109
|
+
keyId: result.key_id || result.share_id,
|
|
110
|
+
encryptedShare: result.encrypted_share || "",
|
|
111
|
+
network
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get Bitcoin address from compressed public key
|
|
116
|
+
*
|
|
117
|
+
* @param publicKey - Compressed public key (33 bytes, hex)
|
|
118
|
+
* @param network - Bitcoin network
|
|
119
|
+
* @param addressType - Address format type (currently not used by API)
|
|
120
|
+
* @returns Bitcoin address
|
|
121
|
+
*/
|
|
122
|
+
async getBitcoinAddress(publicKey, network, _addressType = "bech32") {
|
|
123
|
+
const url = `${this.baseURL}/wapi/v2/btc/address`;
|
|
124
|
+
const params = new URLSearchParams({
|
|
125
|
+
pubkey: publicKey,
|
|
126
|
+
network
|
|
127
|
+
});
|
|
128
|
+
const response = await fetch(`${url}?${params}`, {
|
|
129
|
+
method: "GET",
|
|
130
|
+
headers: {
|
|
131
|
+
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const data = await response.json();
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
throw createAbcError(
|
|
137
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
138
|
+
"Failed to get Bitcoin address",
|
|
139
|
+
data
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
return data.address;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get UTXOs (Unspent Transaction Outputs) for address
|
|
146
|
+
*
|
|
147
|
+
* @param address - Bitcoin address
|
|
148
|
+
* @param network - Bitcoin network
|
|
149
|
+
* @returns Array of UTXOs
|
|
150
|
+
*/
|
|
151
|
+
async getUtxos(address, network) {
|
|
152
|
+
const url = `${this.baseURL}/wapi/v2/bitcoin/utxo/list`;
|
|
153
|
+
const params = new URLSearchParams({ network, address });
|
|
154
|
+
const response = await fetch(`${url}?${params}`, {
|
|
155
|
+
method: "GET",
|
|
156
|
+
headers: {
|
|
157
|
+
...DEFAULT_HEADERS,
|
|
158
|
+
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const data = await response.json();
|
|
162
|
+
if (!response.ok || data.status !== "success") {
|
|
163
|
+
throw createAbcError(
|
|
164
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
165
|
+
"Failed to get UTXOs",
|
|
166
|
+
data
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
return data.result?.utxos || [];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Broadcast signed Bitcoin transaction
|
|
173
|
+
*
|
|
174
|
+
* @param params - Transaction broadcast parameters
|
|
175
|
+
* @returns Transaction hash
|
|
176
|
+
*/
|
|
177
|
+
async sendBitcoinTransaction(params) {
|
|
178
|
+
const url = `${this.baseURL}/wapi/v2/bitcoin/tx/sendTransaction`;
|
|
179
|
+
const response = await fetch(url, {
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers: {
|
|
182
|
+
...DEFAULT_HEADERS,
|
|
183
|
+
...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
|
|
184
|
+
},
|
|
185
|
+
body: JSON.stringify({
|
|
186
|
+
network: params.network,
|
|
187
|
+
rawTransaction: params.rawTransaction,
|
|
188
|
+
...params.psbt && { psbt: params.psbt }
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
const data = await response.json();
|
|
192
|
+
if (!response.ok || data.status !== "success") {
|
|
193
|
+
throw createAbcError(
|
|
194
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
195
|
+
"Failed to send Bitcoin transaction",
|
|
196
|
+
data
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return { txHash: data.result?.data };
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export {
|
|
204
|
+
BitcoinApi
|
|
205
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
createTalkenApiClient
|
|
4
|
+
} from "./chunk-JVT7R2GZ.js";
|
|
5
|
+
import {
|
|
6
|
+
abcConnector
|
|
7
|
+
} from "./chunk-7QL42XTB.js";
|
|
8
|
+
import {
|
|
9
|
+
ABC_WALLET_METADATA
|
|
10
|
+
} from "./chunk-M2U5QGM7.js";
|
|
11
|
+
|
|
12
|
+
// src/wallets/walletConnectors/abcWallet/abcWallet.ts
|
|
13
|
+
import { setTalkenApiClient } from "@talken/talkenkit";
|
|
14
|
+
var abcWallet = (specificOptions) => ({ projectId }) => {
|
|
15
|
+
const talkenApiUrl = specificOptions?.talkenApiUrl || process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001/api/v1";
|
|
16
|
+
const talkenApi = createTalkenApiClient({
|
|
17
|
+
baseUrl: talkenApiUrl,
|
|
18
|
+
debug: specificOptions?.environment === "development"
|
|
19
|
+
});
|
|
20
|
+
setTalkenApiClient(talkenApi);
|
|
21
|
+
const waasUrl = specificOptions?.waasUrl || process.env.NEXT_PUBLIC_ABC_WAAS_URL || process.env.VITE_ABC_WAAS_URL || "";
|
|
22
|
+
const config = {
|
|
23
|
+
waasUrl,
|
|
24
|
+
apiKey: specificOptions?.apiKey,
|
|
25
|
+
plain: specificOptions?.plain || "",
|
|
26
|
+
// Deprecated - not used (secure.ts uses random generation)
|
|
27
|
+
environment: specificOptions?.environment || "development",
|
|
28
|
+
defaultChainId: specificOptions?.defaultChainId,
|
|
29
|
+
defaultSolanaNetwork: specificOptions?.defaultSolanaNetwork,
|
|
30
|
+
defaultBitcoinNetwork: specificOptions?.defaultBitcoinNetwork,
|
|
31
|
+
projectId
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
id: ABC_WALLET_METADATA.id,
|
|
35
|
+
name: ABC_WALLET_METADATA.name,
|
|
36
|
+
rdns: ABC_WALLET_METADATA.rdns,
|
|
37
|
+
iconUrl: async () => (await import("./abcWallet-AYWSIGAG.js")).default,
|
|
38
|
+
iconBackground: ABC_WALLET_METADATA.iconBackground,
|
|
39
|
+
// Embedded wallet - no installation required
|
|
40
|
+
installed: void 0,
|
|
41
|
+
// No download URLs for embedded wallet
|
|
42
|
+
downloadUrls: void 0,
|
|
43
|
+
// Create connector - wrapper function required by Wallet type
|
|
44
|
+
createConnector: (_walletDetails) => abcConnector({ config }),
|
|
45
|
+
// Embedded wallet always available
|
|
46
|
+
hidden: () => false
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
abcWallet
|
|
52
|
+
};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
createAbcEvmProvider
|
|
4
|
+
} from "./chunk-6GCWEPU7.js";
|
|
5
|
+
import {
|
|
6
|
+
createAbcWaasClient
|
|
7
|
+
} from "./chunk-JIJNCMJR.js";
|
|
8
|
+
import {
|
|
9
|
+
setGlobalDefaultBitcoinNetwork,
|
|
10
|
+
setGlobalDefaultChainId,
|
|
11
|
+
setGlobalDefaultSolanaNetwork
|
|
12
|
+
} from "./chunk-O4AU63LK.js";
|
|
13
|
+
import {
|
|
14
|
+
clearAuthState,
|
|
15
|
+
clearEncryptedTokens,
|
|
16
|
+
clearStorage,
|
|
17
|
+
loadAuthState,
|
|
18
|
+
loadFromStorage,
|
|
19
|
+
saveAuthState
|
|
20
|
+
} from "./chunk-LOSXI36Y.js";
|
|
21
|
+
|
|
22
|
+
// src/wallets/walletConnectors/abcWallet/abcConnector.ts
|
|
23
|
+
import { getTalkenApiClient } from "@talken/talkenkit";
|
|
24
|
+
import { createConnector } from "wagmi";
|
|
25
|
+
function abcConnector(options) {
|
|
26
|
+
const { config } = options;
|
|
27
|
+
if (config.defaultChainId) {
|
|
28
|
+
setGlobalDefaultChainId(config.defaultChainId);
|
|
29
|
+
}
|
|
30
|
+
if (config.defaultSolanaNetwork) {
|
|
31
|
+
setGlobalDefaultSolanaNetwork(config.defaultSolanaNetwork);
|
|
32
|
+
}
|
|
33
|
+
if (config.defaultBitcoinNetwork) {
|
|
34
|
+
setGlobalDefaultBitcoinNetwork(config.defaultBitcoinNetwork);
|
|
35
|
+
}
|
|
36
|
+
return createConnector((wagmiConfig) => {
|
|
37
|
+
const client = createAbcWaasClient(config);
|
|
38
|
+
const provider = createAbcEvmProvider(client);
|
|
39
|
+
let accountsChangedHandler;
|
|
40
|
+
let chainChangedHandler;
|
|
41
|
+
let disconnectHandler;
|
|
42
|
+
return {
|
|
43
|
+
id: "abc",
|
|
44
|
+
name: "ABC Wallet",
|
|
45
|
+
type: "abc",
|
|
46
|
+
/**
|
|
47
|
+
* Connect wallet
|
|
48
|
+
*/
|
|
49
|
+
async connect() {
|
|
50
|
+
try {
|
|
51
|
+
const authState = loadAuthState();
|
|
52
|
+
if (!authState || !authState.isAuthenticated || !authState.wallet) {
|
|
53
|
+
throw new Error("ABC_LOGIN_REQUIRED");
|
|
54
|
+
}
|
|
55
|
+
provider.setWallet(authState.wallet);
|
|
56
|
+
if (authState.accessToken && authState.refreshToken && authState.expiresAt) {
|
|
57
|
+
client.setTokens(
|
|
58
|
+
authState.accessToken,
|
|
59
|
+
authState.refreshToken,
|
|
60
|
+
authState.expiresAt
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const accounts = await provider.request({
|
|
64
|
+
method: "eth_requestAccounts"
|
|
65
|
+
});
|
|
66
|
+
let currentChainId = await provider.request({
|
|
67
|
+
method: "eth_chainId"
|
|
68
|
+
});
|
|
69
|
+
const currentChainIdNumber = Number(currentChainId);
|
|
70
|
+
const isChainSupported = wagmiConfig.chains.some(
|
|
71
|
+
(c) => c.id === currentChainIdNumber
|
|
72
|
+
);
|
|
73
|
+
if (!isChainSupported && wagmiConfig.chains.length > 0) {
|
|
74
|
+
const fallbackChainId = wagmiConfig.chains[0].id;
|
|
75
|
+
await provider.request({
|
|
76
|
+
method: "wallet_switchEthereumChain",
|
|
77
|
+
params: [{ chainId: `0x${fallbackChainId.toString(16)}` }]
|
|
78
|
+
});
|
|
79
|
+
currentChainId = `0x${fallbackChainId.toString(16)}`;
|
|
80
|
+
if (authState.wallet) {
|
|
81
|
+
authState.wallet.chainId = fallbackChainId;
|
|
82
|
+
saveAuthState(authState);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (accountsChangedHandler) {
|
|
86
|
+
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
87
|
+
}
|
|
88
|
+
accountsChangedHandler = (accounts2) => {
|
|
89
|
+
wagmiConfig.emitter.emit("change", {
|
|
90
|
+
accounts: accounts2
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
provider.on("accountsChanged", accountsChangedHandler);
|
|
94
|
+
if (chainChangedHandler) {
|
|
95
|
+
provider.removeListener("chainChanged", chainChangedHandler);
|
|
96
|
+
}
|
|
97
|
+
chainChangedHandler = (chainId) => {
|
|
98
|
+
wagmiConfig.emitter.emit("change", {
|
|
99
|
+
chainId: Number(chainId)
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
provider.on("chainChanged", chainChangedHandler);
|
|
103
|
+
if (disconnectHandler) {
|
|
104
|
+
provider.removeListener("disconnect", disconnectHandler);
|
|
105
|
+
}
|
|
106
|
+
disconnectHandler = () => {
|
|
107
|
+
wagmiConfig.emitter.emit("disconnect");
|
|
108
|
+
this.onDisconnect();
|
|
109
|
+
};
|
|
110
|
+
provider.on("disconnect", disconnectHandler);
|
|
111
|
+
wagmiConfig.emitter.emit("connect", {
|
|
112
|
+
accounts,
|
|
113
|
+
chainId: Number(currentChainId)
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
accounts,
|
|
117
|
+
chainId: Number(currentChainId)
|
|
118
|
+
};
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("\u274C ABC Connector connect() failed:", {
|
|
121
|
+
message: error.message,
|
|
122
|
+
code: error.code,
|
|
123
|
+
error
|
|
124
|
+
});
|
|
125
|
+
if (error.message === "ABC_LOGIN_REQUIRED") {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Disconnect wallet
|
|
133
|
+
*/
|
|
134
|
+
async disconnect() {
|
|
135
|
+
if (accountsChangedHandler) {
|
|
136
|
+
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
137
|
+
accountsChangedHandler = void 0;
|
|
138
|
+
}
|
|
139
|
+
if (chainChangedHandler) {
|
|
140
|
+
provider.removeListener("chainChanged", chainChangedHandler);
|
|
141
|
+
chainChangedHandler = void 0;
|
|
142
|
+
}
|
|
143
|
+
if (disconnectHandler) {
|
|
144
|
+
provider.removeListener("disconnect", disconnectHandler);
|
|
145
|
+
disconnectHandler = void 0;
|
|
146
|
+
}
|
|
147
|
+
provider.clearWallet();
|
|
148
|
+
await client.logout();
|
|
149
|
+
let savedPinHash = null;
|
|
150
|
+
let savedEmail = null;
|
|
151
|
+
if (typeof window !== "undefined") {
|
|
152
|
+
savedPinHash = localStorage.getItem("talkenkit_abc_pin_hash");
|
|
153
|
+
savedEmail = localStorage.getItem("talkenkit_abc_saved_email");
|
|
154
|
+
}
|
|
155
|
+
clearAuthState();
|
|
156
|
+
clearEncryptedTokens();
|
|
157
|
+
if (typeof window !== "undefined") {
|
|
158
|
+
localStorage.removeItem("talkenkit_abc_enc_salt");
|
|
159
|
+
localStorage.removeItem("talkenkit_abc_enc_tokens");
|
|
160
|
+
if (savedPinHash) {
|
|
161
|
+
localStorage.setItem("talkenkit_abc_pin_hash", savedPinHash);
|
|
162
|
+
}
|
|
163
|
+
if (savedEmail) {
|
|
164
|
+
localStorage.setItem("talkenkit_abc_saved_email", savedEmail);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
/**
|
|
169
|
+
* Get accounts
|
|
170
|
+
*/
|
|
171
|
+
async getAccounts() {
|
|
172
|
+
const accounts = await provider.request({
|
|
173
|
+
method: "eth_accounts"
|
|
174
|
+
});
|
|
175
|
+
return accounts.map((account) => account);
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Get chain ID
|
|
179
|
+
*/
|
|
180
|
+
async getChainId() {
|
|
181
|
+
const chainId = await provider.request({
|
|
182
|
+
method: "eth_chainId"
|
|
183
|
+
});
|
|
184
|
+
return Number(chainId);
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* Get provider
|
|
188
|
+
*/
|
|
189
|
+
async getProvider() {
|
|
190
|
+
return provider;
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Check if authorized (has valid session)
|
|
194
|
+
* Auto-refreshes access token if expired but refresh token is valid
|
|
195
|
+
*/
|
|
196
|
+
async isAuthorized() {
|
|
197
|
+
try {
|
|
198
|
+
const authState = loadAuthState();
|
|
199
|
+
if (!authState || !authState.isAuthenticated) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
if (!authState.wallet) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (client.isAuthenticated()) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
const refreshToken = loadFromStorage(
|
|
209
|
+
"refresh_token" /* REFRESH_TOKEN */
|
|
210
|
+
);
|
|
211
|
+
if (!refreshToken) {
|
|
212
|
+
clearStorage();
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const api = getTalkenApiClient();
|
|
217
|
+
if (!api) {
|
|
218
|
+
clearStorage();
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
const res = await api.auth.refresh();
|
|
222
|
+
client.setTokens(
|
|
223
|
+
res.accessToken,
|
|
224
|
+
res.refreshToken,
|
|
225
|
+
Date.now() + res.expiresIn * 1e3
|
|
226
|
+
);
|
|
227
|
+
const updatedState = loadAuthState();
|
|
228
|
+
return updatedState?.isAuthenticated ?? false;
|
|
229
|
+
} catch (error) {
|
|
230
|
+
console.error("[AbcConnector] Token refresh failed:", error);
|
|
231
|
+
clearStorage();
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.error(
|
|
236
|
+
"[AbcConnector] Unexpected error in isAuthorized:",
|
|
237
|
+
error
|
|
238
|
+
);
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
/**
|
|
243
|
+
* Switch chain
|
|
244
|
+
*/
|
|
245
|
+
async switchChain({ chainId }) {
|
|
246
|
+
await provider.request({
|
|
247
|
+
method: "wallet_switchEthereumChain",
|
|
248
|
+
params: [{ chainId: `0x${chainId.toString(16)}` }]
|
|
249
|
+
});
|
|
250
|
+
const newChainId = await this.getChainId();
|
|
251
|
+
const authState = loadAuthState();
|
|
252
|
+
if (authState?.wallet) {
|
|
253
|
+
authState.wallet.chainId = newChainId;
|
|
254
|
+
saveAuthState(authState);
|
|
255
|
+
}
|
|
256
|
+
return wagmiConfig.chains.find((x) => x.id === chainId) ?? {
|
|
257
|
+
id: chainId,
|
|
258
|
+
name: `Chain ${chainId}`,
|
|
259
|
+
nativeCurrency: {
|
|
260
|
+
name: "Ether",
|
|
261
|
+
decimals: 18,
|
|
262
|
+
symbol: "ETH"
|
|
263
|
+
},
|
|
264
|
+
rpcUrls: {
|
|
265
|
+
default: { http: [""] }
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
/**
|
|
270
|
+
* Handle accounts changed
|
|
271
|
+
*/
|
|
272
|
+
onAccountsChanged(accounts) {
|
|
273
|
+
if (accounts.length === 0) {
|
|
274
|
+
this.onDisconnect();
|
|
275
|
+
} else {
|
|
276
|
+
wagmiConfig.emitter.emit("change", {
|
|
277
|
+
accounts
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
/**
|
|
282
|
+
* Handle chain changed
|
|
283
|
+
*/
|
|
284
|
+
onChainChanged(chain) {
|
|
285
|
+
const chainId = Number(chain);
|
|
286
|
+
wagmiConfig.emitter.emit("change", { chainId });
|
|
287
|
+
},
|
|
288
|
+
/**
|
|
289
|
+
* Handle disconnect
|
|
290
|
+
*/
|
|
291
|
+
onDisconnect(_error) {
|
|
292
|
+
provider.clearWallet();
|
|
293
|
+
clearAuthState();
|
|
294
|
+
wagmiConfig.emitter.emit("disconnect");
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export {
|
|
301
|
+
abcConnector
|
|
302
|
+
};
|