@talken/talkenkit 2.4.24 → 2.4.26
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 +7 -0
- package/dist/abcWallet-GFKDYN2Z.js +161 -0
- package/dist/abcWallet-MWUFO3JQ.js +161 -0
- package/dist/abcWallet-OL47MLVO.js +161 -0
- package/dist/abcWallet-VYU3TEGJ.js +161 -0
- package/dist/abcWallet-WZGXGXUA.js +161 -0
- package/dist/chunk-2OHX4KTB.js +5382 -0
- package/dist/chunk-ALBABQ53.js +354 -0
- package/dist/chunk-NQCUKFAV.js +5381 -0
- package/dist/chunk-RIEG3EJO.js +5385 -0
- package/dist/chunk-RKEFBYBO.js +5402 -0
- package/dist/chunk-UKIPSWEV.js +5386 -0
- package/dist/hooks/useProfile.d.ts +13 -6
- package/dist/hooks/useSolanaWallet.d.ts +9 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +276 -181
- package/dist/providers/SignConfirmationProvider/useApiClient.d.ts +3 -0
- package/dist/solana/ConfiguredWalletProvider.d.ts +10 -0
- package/dist/solana/LegacySolflareWalletAdapter.d.ts +32 -0
- package/dist/solana/connectExternalWallet.d.ts +9 -0
- package/dist/solana/isWalletReady.d.ts +2 -0
- package/dist/transactions/transactionStore.d.ts +2 -5
- package/dist/utils/apiClientFactory.d.ts +16 -1
- package/dist/wallets/capabilities/detectCapabilities.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +2 -2
- 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 +6 -6
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.d.ts +0 -4
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +11 -3
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +5 -5
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +7 -7
- package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.d.ts +21 -0
- package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +8 -0
- package/dist/wallets/walletConnectors/abcWallet/api/SolanaApi.d.ts +28 -115
- package/dist/wallets/walletConnectors/abcWallet/api/SolanaApi.js +1 -6
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +23 -1
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.d.ts +14 -0
- package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +8 -0
- package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.d.ts +20 -0
- package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/api/index.d.ts +3 -0
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +17 -5
- package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +4 -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 +33 -21
- package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/types.d.ts +4 -0
- package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +3 -3
- package/dist/wallets/walletConnectors/chunk-6WF4SXLB.js +156 -0
- package/dist/wallets/walletConnectors/chunk-7DM6H5BJ.js +54 -0
- package/dist/wallets/walletConnectors/chunk-7F5DVU5U.js +300 -0
- package/dist/wallets/walletConnectors/chunk-7ORDZ6EQ.js +1479 -0
- package/dist/wallets/walletConnectors/chunk-A66MTFML.js +223 -0
- package/dist/wallets/walletConnectors/chunk-ACLPF2UW.js +96 -0
- package/dist/wallets/walletConnectors/chunk-BXH3GDX5.js +273 -0
- package/dist/wallets/walletConnectors/chunk-CABLJOMU.js +194 -0
- package/dist/wallets/walletConnectors/chunk-CE37VZAR.js +300 -0
- package/dist/wallets/walletConnectors/chunk-DPTDOCWL.js +205 -0
- package/dist/wallets/walletConnectors/chunk-E7TDM6P6.js +205 -0
- package/dist/wallets/walletConnectors/chunk-GBMOX5JN.js +54 -0
- package/dist/wallets/walletConnectors/chunk-GWYZ2IPP.js +1479 -0
- package/dist/wallets/walletConnectors/chunk-HF6GFAE5.js +54 -0
- package/dist/wallets/walletConnectors/chunk-IM7DEERX.js +585 -0
- package/dist/wallets/walletConnectors/chunk-INFMRNND.js +300 -0
- package/dist/wallets/walletConnectors/chunk-JADQLTFW.js +194 -0
- package/dist/wallets/walletConnectors/chunk-JGXJY3SB.js +1 -0
- package/dist/wallets/walletConnectors/chunk-K3VHBOXQ.js +32 -0
- package/dist/wallets/walletConnectors/chunk-KZS2C73S.js +814 -0
- package/dist/wallets/walletConnectors/chunk-L6EUMSX2.js +54 -0
- package/dist/wallets/walletConnectors/chunk-LJNUFDGO.js +205 -0
- package/dist/wallets/walletConnectors/chunk-MO2AXXLI.js +30 -0
- package/dist/wallets/walletConnectors/chunk-NYDDRNUI.js +445 -0
- package/dist/wallets/walletConnectors/chunk-O4DNG6JJ.js +54 -0
- package/dist/wallets/walletConnectors/chunk-OMOYFHBT.js +1485 -0
- package/dist/wallets/walletConnectors/chunk-OTLZVWY7.js +39 -0
- package/dist/wallets/walletConnectors/chunk-PDXO6AOG.js +300 -0
- package/dist/wallets/walletConnectors/chunk-VDWJ3NQ5.js +52 -0
- package/dist/wallets/walletConnectors/chunk-VKOPUEQG.js +445 -0
- package/dist/wallets/walletConnectors/chunk-VTOD7PXP.js +817 -0
- package/dist/wallets/walletConnectors/chunk-WC7BGU5Z.js +814 -0
- package/dist/wallets/walletConnectors/chunk-YDSBY7NO.js +54 -0
- package/dist/wallets/walletConnectors/chunk-YV6IZWGE.js +393 -0
- package/dist/wallets/walletConnectors/chunk-Z5SBGIWT.js +300 -0
- package/dist/wallets/walletConnectors/chunk-ZKCUYHBK.js +300 -0
- package/dist/wallets/walletConnectors/index.js +90 -90
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/wallets/walletConnectors/abcWallet/api/SolanaApi.ts
|
|
4
|
+
import { getTalkenApiClient } from "@talken/talkenkit";
|
|
5
|
+
var SolanaApi = class {
|
|
6
|
+
async getLatestBlockhash(network) {
|
|
7
|
+
const api = getTalkenApiClient();
|
|
8
|
+
if (!api)
|
|
9
|
+
throw new Error("TalkenApiClient not initialized");
|
|
10
|
+
return api.solana.getLatestBlockhash(network);
|
|
11
|
+
}
|
|
12
|
+
async getTransactionStatus(params) {
|
|
13
|
+
const api = getTalkenApiClient();
|
|
14
|
+
if (!api)
|
|
15
|
+
throw new Error("TalkenApiClient not initialized");
|
|
16
|
+
return api.solana.getTransactionStatus(params);
|
|
17
|
+
}
|
|
18
|
+
async waitForTransactionStatus(params, options = {}) {
|
|
19
|
+
const { timeoutMs = 6e4, pollIntervalMs = 1500 } = options;
|
|
20
|
+
const deadline = Date.now() + timeoutMs;
|
|
21
|
+
while (Date.now() < deadline) {
|
|
22
|
+
const status = await this.getTransactionStatus(params);
|
|
23
|
+
if (status.found) {
|
|
24
|
+
if (status.err) {
|
|
25
|
+
throw new Error("Solana transaction failed");
|
|
26
|
+
}
|
|
27
|
+
if (status.confirmationStatus === "confirmed" || status.confirmationStatus === "finalized") {
|
|
28
|
+
return status;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Timed out waiting for Solana transaction confirmation");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
SolanaApi
|
|
39
|
+
};
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
setTalkenApiClient
|
|
4
|
+
} from "./chunk-R6ZE7JAZ.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveTalkenApiUrl
|
|
7
|
+
} from "./chunk-GFWUFYT2.js";
|
|
8
|
+
import {
|
|
9
|
+
setGlobalDefaultBitcoinNetwork,
|
|
10
|
+
setGlobalDefaultChainId,
|
|
11
|
+
setGlobalDefaultSolanaNetwork
|
|
12
|
+
} from "./chunk-O4AU63LK.js";
|
|
13
|
+
import {
|
|
14
|
+
createAbcEvmProvider
|
|
15
|
+
} from "./chunk-GWYZ2IPP.js";
|
|
16
|
+
import {
|
|
17
|
+
clearAuthState,
|
|
18
|
+
clearStorage,
|
|
19
|
+
loadAuthState,
|
|
20
|
+
loadFromStorage,
|
|
21
|
+
saveAuthState
|
|
22
|
+
} from "./chunk-A66MTFML.js";
|
|
23
|
+
import {
|
|
24
|
+
createTalkenApiClient
|
|
25
|
+
} from "./chunk-KZS2C73S.js";
|
|
26
|
+
import {
|
|
27
|
+
getCredentialManager
|
|
28
|
+
} from "./chunk-6WF4SXLB.js";
|
|
29
|
+
|
|
30
|
+
// src/wallets/walletConnectors/abcWallet/abcConnector.ts
|
|
31
|
+
import { getTalkenApiClient } from "@talken/talkenkit";
|
|
32
|
+
import { createConnector } from "wagmi";
|
|
33
|
+
function abcConnector(options) {
|
|
34
|
+
const { config } = options;
|
|
35
|
+
if (config.defaultChainId) {
|
|
36
|
+
setGlobalDefaultChainId(config.defaultChainId);
|
|
37
|
+
}
|
|
38
|
+
if (config.defaultSolanaNetwork) {
|
|
39
|
+
setGlobalDefaultSolanaNetwork(config.defaultSolanaNetwork);
|
|
40
|
+
}
|
|
41
|
+
if (config.defaultBitcoinNetwork) {
|
|
42
|
+
setGlobalDefaultBitcoinNetwork(config.defaultBitcoinNetwork);
|
|
43
|
+
}
|
|
44
|
+
return createConnector((wagmiConfig) => {
|
|
45
|
+
const talkenApi = getTalkenApiClient() || createTalkenApiClient({
|
|
46
|
+
baseUrl: resolveTalkenApiUrl(config.talkenApiUrl),
|
|
47
|
+
environment: config.environment,
|
|
48
|
+
debug: config.environment === "development",
|
|
49
|
+
defaultChainId: config.defaultChainId
|
|
50
|
+
});
|
|
51
|
+
setTalkenApiClient(talkenApi);
|
|
52
|
+
const provider = createAbcEvmProvider(talkenApi);
|
|
53
|
+
let accountsChangedHandler;
|
|
54
|
+
let chainChangedHandler;
|
|
55
|
+
let disconnectHandler;
|
|
56
|
+
return {
|
|
57
|
+
id: "abc",
|
|
58
|
+
name: "ABC Wallet",
|
|
59
|
+
type: "abc",
|
|
60
|
+
/**
|
|
61
|
+
* Connect wallet
|
|
62
|
+
*/
|
|
63
|
+
async connect() {
|
|
64
|
+
try {
|
|
65
|
+
const authState = loadAuthState();
|
|
66
|
+
if (!authState || !authState.isAuthenticated || !authState.wallet) {
|
|
67
|
+
throw new Error("ABC_LOGIN_REQUIRED");
|
|
68
|
+
}
|
|
69
|
+
provider.setWallet(authState.wallet);
|
|
70
|
+
if (authState.accessToken && authState.refreshToken && authState.expiresAt) {
|
|
71
|
+
talkenApi.setTokens(
|
|
72
|
+
authState.accessToken,
|
|
73
|
+
authState.refreshToken,
|
|
74
|
+
authState.expiresAt
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const accounts = await provider.request({
|
|
78
|
+
method: "eth_requestAccounts"
|
|
79
|
+
});
|
|
80
|
+
let currentChainId = await provider.request({
|
|
81
|
+
method: "eth_chainId"
|
|
82
|
+
});
|
|
83
|
+
const currentChainIdNumber = Number(currentChainId);
|
|
84
|
+
const isChainSupported = wagmiConfig.chains.some(
|
|
85
|
+
(c) => c.id === currentChainIdNumber
|
|
86
|
+
);
|
|
87
|
+
if (!isChainSupported && wagmiConfig.chains.length > 0) {
|
|
88
|
+
const fallbackChainId = wagmiConfig.chains[0].id;
|
|
89
|
+
await provider.request({
|
|
90
|
+
method: "wallet_switchEthereumChain",
|
|
91
|
+
params: [{ chainId: `0x${fallbackChainId.toString(16)}` }]
|
|
92
|
+
});
|
|
93
|
+
currentChainId = `0x${fallbackChainId.toString(16)}`;
|
|
94
|
+
if (authState.wallet) {
|
|
95
|
+
authState.wallet.chainId = fallbackChainId;
|
|
96
|
+
saveAuthState(authState);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (accountsChangedHandler) {
|
|
100
|
+
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
101
|
+
}
|
|
102
|
+
accountsChangedHandler = (accounts2) => {
|
|
103
|
+
wagmiConfig.emitter.emit("change", {
|
|
104
|
+
accounts: accounts2
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
provider.on("accountsChanged", accountsChangedHandler);
|
|
108
|
+
if (chainChangedHandler) {
|
|
109
|
+
provider.removeListener("chainChanged", chainChangedHandler);
|
|
110
|
+
}
|
|
111
|
+
chainChangedHandler = (chainId) => {
|
|
112
|
+
wagmiConfig.emitter.emit("change", {
|
|
113
|
+
chainId: Number(chainId)
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
provider.on("chainChanged", chainChangedHandler);
|
|
117
|
+
if (disconnectHandler) {
|
|
118
|
+
provider.removeListener("disconnect", disconnectHandler);
|
|
119
|
+
}
|
|
120
|
+
disconnectHandler = () => {
|
|
121
|
+
wagmiConfig.emitter.emit("disconnect");
|
|
122
|
+
this.onDisconnect();
|
|
123
|
+
};
|
|
124
|
+
provider.on("disconnect", disconnectHandler);
|
|
125
|
+
wagmiConfig.emitter.emit("connect", {
|
|
126
|
+
accounts,
|
|
127
|
+
chainId: Number(currentChainId)
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
accounts,
|
|
131
|
+
chainId: Number(currentChainId)
|
|
132
|
+
};
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error("\u274C ABC Connector connect() failed:", {
|
|
135
|
+
message: error.message,
|
|
136
|
+
code: error.code,
|
|
137
|
+
error
|
|
138
|
+
});
|
|
139
|
+
if (error.message === "ABC_LOGIN_REQUIRED") {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Disconnect wallet
|
|
147
|
+
*/
|
|
148
|
+
async disconnect() {
|
|
149
|
+
if (accountsChangedHandler) {
|
|
150
|
+
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
151
|
+
accountsChangedHandler = void 0;
|
|
152
|
+
}
|
|
153
|
+
if (chainChangedHandler) {
|
|
154
|
+
provider.removeListener("chainChanged", chainChangedHandler);
|
|
155
|
+
chainChangedHandler = void 0;
|
|
156
|
+
}
|
|
157
|
+
if (disconnectHandler) {
|
|
158
|
+
provider.removeListener("disconnect", disconnectHandler);
|
|
159
|
+
disconnectHandler = void 0;
|
|
160
|
+
}
|
|
161
|
+
provider.clearWallet();
|
|
162
|
+
talkenApi.auth.logout();
|
|
163
|
+
clearAuthState();
|
|
164
|
+
getCredentialManager().clear();
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* Get accounts
|
|
168
|
+
*/
|
|
169
|
+
async getAccounts() {
|
|
170
|
+
const accounts = await provider.request({
|
|
171
|
+
method: "eth_accounts"
|
|
172
|
+
});
|
|
173
|
+
return accounts.map((account) => account);
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* Get chain ID
|
|
177
|
+
*/
|
|
178
|
+
async getChainId() {
|
|
179
|
+
const chainId = await provider.request({
|
|
180
|
+
method: "eth_chainId"
|
|
181
|
+
});
|
|
182
|
+
return Number(chainId);
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* Get provider
|
|
186
|
+
*/
|
|
187
|
+
async getProvider() {
|
|
188
|
+
return provider;
|
|
189
|
+
},
|
|
190
|
+
/**
|
|
191
|
+
* Check if authorized (has valid session)
|
|
192
|
+
* Auto-refreshes access token if expired but refresh token is valid
|
|
193
|
+
*/
|
|
194
|
+
async isAuthorized() {
|
|
195
|
+
try {
|
|
196
|
+
const authState = loadAuthState();
|
|
197
|
+
if (!authState || !authState.isAuthenticated) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
if (!authState.wallet) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
if (talkenApi.isAuthenticated()) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
const refreshToken = loadFromStorage(
|
|
207
|
+
"refresh_token" /* REFRESH_TOKEN */
|
|
208
|
+
);
|
|
209
|
+
if (!refreshToken) {
|
|
210
|
+
clearStorage();
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const api = getTalkenApiClient();
|
|
215
|
+
if (!api) {
|
|
216
|
+
clearStorage();
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const res = await api.auth.refresh();
|
|
220
|
+
talkenApi.setTokens(
|
|
221
|
+
res.accessToken,
|
|
222
|
+
res.refreshToken,
|
|
223
|
+
Date.now() + res.expiresIn * 1e3
|
|
224
|
+
);
|
|
225
|
+
const updatedState = loadAuthState();
|
|
226
|
+
return updatedState?.isAuthenticated ?? false;
|
|
227
|
+
} catch (error) {
|
|
228
|
+
console.error("[AbcConnector] Token refresh failed:", error);
|
|
229
|
+
clearStorage();
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error(
|
|
234
|
+
"[AbcConnector] Unexpected error in isAuthorized:",
|
|
235
|
+
error
|
|
236
|
+
);
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
/**
|
|
241
|
+
* Switch chain
|
|
242
|
+
*/
|
|
243
|
+
async switchChain({ chainId }) {
|
|
244
|
+
await provider.request({
|
|
245
|
+
method: "wallet_switchEthereumChain",
|
|
246
|
+
params: [{ chainId: `0x${chainId.toString(16)}` }]
|
|
247
|
+
});
|
|
248
|
+
const newChainId = await this.getChainId();
|
|
249
|
+
const authState = loadAuthState();
|
|
250
|
+
if (authState?.wallet) {
|
|
251
|
+
authState.wallet.chainId = newChainId;
|
|
252
|
+
saveAuthState(authState);
|
|
253
|
+
}
|
|
254
|
+
return wagmiConfig.chains.find((x) => x.id === chainId) ?? {
|
|
255
|
+
id: chainId,
|
|
256
|
+
name: `Chain ${chainId}`,
|
|
257
|
+
nativeCurrency: {
|
|
258
|
+
name: "Ether",
|
|
259
|
+
decimals: 18,
|
|
260
|
+
symbol: "ETH"
|
|
261
|
+
},
|
|
262
|
+
rpcUrls: {
|
|
263
|
+
default: { http: [""] }
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
/**
|
|
268
|
+
* Handle accounts changed
|
|
269
|
+
*/
|
|
270
|
+
onAccountsChanged(accounts) {
|
|
271
|
+
if (accounts.length === 0) {
|
|
272
|
+
this.onDisconnect();
|
|
273
|
+
} else {
|
|
274
|
+
wagmiConfig.emitter.emit("change", {
|
|
275
|
+
accounts
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
/**
|
|
280
|
+
* Handle chain changed
|
|
281
|
+
*/
|
|
282
|
+
onChainChanged(chain) {
|
|
283
|
+
const chainId = Number(chain);
|
|
284
|
+
wagmiConfig.emitter.emit("change", { chainId });
|
|
285
|
+
},
|
|
286
|
+
/**
|
|
287
|
+
* Handle disconnect
|
|
288
|
+
*/
|
|
289
|
+
onDisconnect(_error) {
|
|
290
|
+
provider.clearWallet();
|
|
291
|
+
clearAuthState();
|
|
292
|
+
wagmiConfig.emitter.emit("disconnect");
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export {
|
|
299
|
+
abcConnector
|
|
300
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
TALKEN_API_ENDPOINTS
|
|
4
|
+
} from "./chunk-DPTDOCWL.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
|
+
};
|