@talken/talkenkit 2.4.25 → 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/abcWallet-GFKDYN2Z.js +161 -0
- package/dist/chunk-RKEFBYBO.js +5402 -0
- package/dist/index.js +14 -10
- package/dist/wallets/capabilities/detectCapabilities.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/index.js +3 -3
- 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-7F5DVU5U.js +300 -0
- package/dist/wallets/walletConnectors/chunk-L6EUMSX2.js +54 -0
- package/dist/wallets/walletConnectors/chunk-OMOYFHBT.js +1485 -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 +1 -1
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
networkToChainId,
|
|
54
54
|
resolveTalkenApiUrl,
|
|
55
55
|
setTalkenApiClient
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-RKEFBYBO.js";
|
|
57
57
|
import {
|
|
58
58
|
STORAGE_PREFIX,
|
|
59
59
|
getCredentialManager
|
|
@@ -158,7 +158,7 @@ function useBitcoinWallet() {
|
|
|
158
158
|
wallet: bitcoinWallet,
|
|
159
159
|
emptyState: emptyWalletState,
|
|
160
160
|
requestInterceptor,
|
|
161
|
-
importProvider: async () => (await import("./abcWallet-
|
|
161
|
+
importProvider: async () => (await import("./abcWallet-GFKDYN2Z.js")).AbcBitcoinProvider,
|
|
162
162
|
mapState: (nextWallet, provider) => ({
|
|
163
163
|
address: nextWallet.address,
|
|
164
164
|
publicKey: nextWallet.publicKey,
|
|
@@ -1329,7 +1329,7 @@ function useSolanaWallet() {
|
|
|
1329
1329
|
wallet: solanaWallet,
|
|
1330
1330
|
emptyState: emptyWalletState,
|
|
1331
1331
|
requestInterceptor,
|
|
1332
|
-
importProvider: async () => (await import("./abcWallet-
|
|
1332
|
+
importProvider: async () => (await import("./abcWallet-GFKDYN2Z.js")).AbcSolanaProvider,
|
|
1333
1333
|
mapState: (nextWallet, provider) => ({
|
|
1334
1334
|
address: nextWallet.address,
|
|
1335
1335
|
publicKey: nextWallet.publicKey,
|
|
@@ -8033,7 +8033,7 @@ function setRainbowKitVersion({ version }) {
|
|
|
8033
8033
|
}
|
|
8034
8034
|
function useFingerprint() {
|
|
8035
8035
|
const fingerprint = useCallback14(() => {
|
|
8036
|
-
setRainbowKitVersion({ version: "2.4.
|
|
8036
|
+
setRainbowKitVersion({ version: "2.4.26" });
|
|
8037
8037
|
}, []);
|
|
8038
8038
|
useEffect19(() => {
|
|
8039
8039
|
fingerprint();
|
|
@@ -10368,9 +10368,10 @@ function AbcWaasAuthSections(props) {
|
|
|
10368
10368
|
setAbcWaasConfirmPassword
|
|
10369
10369
|
} = props;
|
|
10370
10370
|
const [email, setEmail] = useState24("");
|
|
10371
|
-
const
|
|
10372
|
-
const
|
|
10373
|
-
const
|
|
10371
|
+
const isTelegramMiniApp = typeof window !== "undefined" && !!window.Telegram?.WebApp && window.Telegram.WebApp.platform !== "unknown";
|
|
10372
|
+
const isGoogleEnabled = !isTelegramMiniApp && typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_GOOGLE_OAUTH_ENABLED === "true" && !!process.env.NEXT_PUBLIC_FIREBASE_API_KEY;
|
|
10373
|
+
const isAppleEnabled = !isTelegramMiniApp && typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_APPLE_OAUTH_ENABLED === "true" && !!process.env.NEXT_PUBLIC_APPLE_OAUTH_CLIENT_ID;
|
|
10374
|
+
const isKakaoEnabled = !isTelegramMiniApp && typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_KAKAO_OAUTH_ENABLED === "true" && !!process.env.NEXT_PUBLIC_KAKAO_JS_KEY;
|
|
10374
10375
|
const hasSocialLogin = isGoogleEnabled || isAppleEnabled || isKakaoEnabled;
|
|
10375
10376
|
const handleEmailFormSubmit = (e) => {
|
|
10376
10377
|
e.preventDefault();
|
|
@@ -17441,7 +17442,9 @@ async function detectCapabilities(params) {
|
|
|
17441
17442
|
const fallback = defaultCapabilities(walletType);
|
|
17442
17443
|
try {
|
|
17443
17444
|
const raw = await requestWalletAction(params.walletClient, {
|
|
17444
|
-
method: "wallet_getCapabilities"
|
|
17445
|
+
method: "wallet_getCapabilities",
|
|
17446
|
+
// EIP-5792: wallet_getCapabilities requires [address] param
|
|
17447
|
+
...params.address ? { params: [params.address] } : {}
|
|
17445
17448
|
});
|
|
17446
17449
|
const value = isRecord2(raw) ? raw : {};
|
|
17447
17450
|
return {
|
|
@@ -17473,7 +17476,8 @@ function useWalletCapabilities() {
|
|
|
17473
17476
|
const next = await detectCapabilities({
|
|
17474
17477
|
walletClient,
|
|
17475
17478
|
connectorId: connector?.id ?? null,
|
|
17476
|
-
connectorName: connector?.name ?? null
|
|
17479
|
+
connectorName: connector?.name ?? null,
|
|
17480
|
+
address: address ?? null
|
|
17477
17481
|
});
|
|
17478
17482
|
setCapabilities(next);
|
|
17479
17483
|
} finally {
|
|
@@ -17997,7 +18001,7 @@ function useTronWallet() {
|
|
|
17997
18001
|
wallet: tronWallet,
|
|
17998
18002
|
emptyState: emptyWalletState,
|
|
17999
18003
|
requestInterceptor,
|
|
18000
|
-
importProvider: async () => (await import("./abcWallet-
|
|
18004
|
+
importProvider: async () => (await import("./abcWallet-GFKDYN2Z.js")).AbcTronProvider,
|
|
18001
18005
|
mapState: (nextWallet, provider) => ({
|
|
18002
18006
|
address: nextWallet.address,
|
|
18003
18007
|
publicKey: nextWallet.publicKey,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
abcConnector
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-7F5DVU5U.js";
|
|
5
5
|
import "../chunk-R6ZE7JAZ.js";
|
|
6
6
|
import "../chunk-O4AU63LK.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-OMOYFHBT.js";
|
|
8
8
|
import "../chunk-A66MTFML.js";
|
|
9
9
|
import "../chunk-GFWUFYT2.js";
|
|
10
10
|
import "../chunk-VTOD7PXP.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
abcWallet
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-L6EUMSX2.js";
|
|
5
|
+
import "../chunk-7F5DVU5U.js";
|
|
6
6
|
import "../chunk-R6ZE7JAZ.js";
|
|
7
7
|
import "../chunk-O4AU63LK.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-OMOYFHBT.js";
|
|
9
9
|
import "../chunk-A66MTFML.js";
|
|
10
10
|
import "../chunk-GFWUFYT2.js";
|
|
11
11
|
import "../chunk-VTOD7PXP.js";
|
|
@@ -47,10 +47,10 @@ import {
|
|
|
47
47
|
} from "../chunk-OTLZVWY7.js";
|
|
48
48
|
import {
|
|
49
49
|
abcWallet
|
|
50
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-L6EUMSX2.js";
|
|
51
51
|
import {
|
|
52
52
|
abcConnector
|
|
53
|
-
} from "../chunk-
|
|
53
|
+
} from "../chunk-7F5DVU5U.js";
|
|
54
54
|
import "../chunk-R6ZE7JAZ.js";
|
|
55
55
|
import {
|
|
56
56
|
BitcoinNetwork,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
AbcEvmProvider,
|
|
66
66
|
createAbcEvmProvider,
|
|
67
67
|
createAbcProvider
|
|
68
|
-
} from "../chunk-
|
|
68
|
+
} from "../chunk-OMOYFHBT.js";
|
|
69
69
|
import {
|
|
70
70
|
calculateExpiryTimestamp,
|
|
71
71
|
clearAuthState,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
bifrostWallet
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-WXXI4WBF.js";
|
|
5
5
|
import "../chunk-RETKWSKD.js";
|
|
6
|
-
import "../chunk-MBBGZGXF.js";
|
|
7
6
|
import "../chunk-PODFK4OS.js";
|
|
7
|
+
import "../chunk-MBBGZGXF.js";
|
|
8
8
|
export {
|
|
9
9
|
bifrostWallet
|
|
10
10
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
binanceWallet
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-TUDZHFVC.js";
|
|
5
5
|
import "../chunk-RETKWSKD.js";
|
|
6
|
-
import "../chunk-MBBGZGXF.js";
|
|
7
6
|
import "../chunk-PODFK4OS.js";
|
|
7
|
+
import "../chunk-MBBGZGXF.js";
|
|
8
8
|
export {
|
|
9
9
|
binanceWallet
|
|
10
10
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
bitgetWallet
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ITLTDJ3D.js";
|
|
5
5
|
import "../chunk-RETKWSKD.js";
|
|
6
|
-
import "../chunk-MBBGZGXF.js";
|
|
7
6
|
import "../chunk-PODFK4OS.js";
|
|
7
|
+
import "../chunk-MBBGZGXF.js";
|
|
8
8
|
export {
|
|
9
9
|
bitgetWallet
|
|
10
10
|
};
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
setTalkenApiClient
|
|
4
|
+
} from "./chunk-R6ZE7JAZ.js";
|
|
5
|
+
import {
|
|
6
|
+
setGlobalDefaultBitcoinNetwork,
|
|
7
|
+
setGlobalDefaultChainId,
|
|
8
|
+
setGlobalDefaultSolanaNetwork
|
|
9
|
+
} from "./chunk-O4AU63LK.js";
|
|
10
|
+
import {
|
|
11
|
+
createAbcEvmProvider
|
|
12
|
+
} from "./chunk-OMOYFHBT.js";
|
|
13
|
+
import {
|
|
14
|
+
clearAuthState,
|
|
15
|
+
clearStorage,
|
|
16
|
+
loadAuthState,
|
|
17
|
+
loadFromStorage,
|
|
18
|
+
saveAuthState
|
|
19
|
+
} from "./chunk-A66MTFML.js";
|
|
20
|
+
import {
|
|
21
|
+
resolveTalkenApiUrl
|
|
22
|
+
} from "./chunk-GFWUFYT2.js";
|
|
23
|
+
import {
|
|
24
|
+
createTalkenApiClient
|
|
25
|
+
} from "./chunk-VTOD7PXP.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,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
abcConnector
|
|
4
|
+
} from "./chunk-7F5DVU5U.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveTalkenApiUrl
|
|
7
|
+
} from "./chunk-GFWUFYT2.js";
|
|
8
|
+
import {
|
|
9
|
+
createTalkenApiClient
|
|
10
|
+
} from "./chunk-VTOD7PXP.js";
|
|
11
|
+
import {
|
|
12
|
+
ABC_WALLET_METADATA
|
|
13
|
+
} from "./chunk-DPTDOCWL.js";
|
|
14
|
+
|
|
15
|
+
// src/wallets/walletConnectors/abcWallet/abcWallet.ts
|
|
16
|
+
import { setTalkenApiClient } from "@talken/talkenkit";
|
|
17
|
+
var abcWallet = (specificOptions) => ({ projectId }) => {
|
|
18
|
+
const talkenApiUrl = resolveTalkenApiUrl(specificOptions?.talkenApiUrl);
|
|
19
|
+
const talkenApi = createTalkenApiClient({
|
|
20
|
+
baseUrl: talkenApiUrl,
|
|
21
|
+
debug: specificOptions?.environment === "development"
|
|
22
|
+
});
|
|
23
|
+
setTalkenApiClient(talkenApi);
|
|
24
|
+
const config = {
|
|
25
|
+
talkenApiUrl,
|
|
26
|
+
apiKey: specificOptions?.apiKey,
|
|
27
|
+
plain: specificOptions?.plain || "",
|
|
28
|
+
// Deprecated - not used (secure.ts uses random generation)
|
|
29
|
+
environment: specificOptions?.environment || "development",
|
|
30
|
+
defaultChainId: specificOptions?.defaultChainId,
|
|
31
|
+
defaultSolanaNetwork: specificOptions?.defaultSolanaNetwork,
|
|
32
|
+
defaultBitcoinNetwork: specificOptions?.defaultBitcoinNetwork,
|
|
33
|
+
projectId
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
id: ABC_WALLET_METADATA.id,
|
|
37
|
+
name: ABC_WALLET_METADATA.name,
|
|
38
|
+
rdns: ABC_WALLET_METADATA.rdns,
|
|
39
|
+
iconUrl: async () => (await import("./abcWallet-AYWSIGAG.js")).default,
|
|
40
|
+
iconBackground: ABC_WALLET_METADATA.iconBackground,
|
|
41
|
+
// Embedded wallet - no installation required
|
|
42
|
+
installed: void 0,
|
|
43
|
+
// No download URLs for embedded wallet
|
|
44
|
+
downloadUrls: void 0,
|
|
45
|
+
// Create connector - wrapper function required by Wallet type
|
|
46
|
+
createConnector: (_walletDetails) => abcConnector({ config }),
|
|
47
|
+
// Embedded wallet always available
|
|
48
|
+
hidden: () => false
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
abcWallet
|
|
54
|
+
};
|