@talken/talkenkit 2.4.12 → 2.4.13
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-4Y7KXZBE.js +184 -0
- package/dist/abcWallet-KPGRZYCP.js +184 -0
- package/dist/abcWallet-NTVWBYWF.js +184 -0
- package/dist/abcWallet-S7EO644R.js +184 -0
- package/dist/chunk-GG57EUYL.js +7132 -0
- package/dist/chunk-MLJXZ6R2.js +7130 -0
- package/dist/chunk-NWF5NI55.js +7130 -0
- package/dist/chunk-ZRBHEE5W.js +7130 -0
- package/dist/index.js +44 -8
- package/dist/wallets/walletConnectors/abcWallet/abcApi.d.ts +8 -0
- package/dist/wallets/walletConnectors/abcWallet/abcApi.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +4 -0
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/index.js +4 -4
- package/dist/wallets/walletConnectors/chunk-2KHZAE46.js +47 -0
- package/dist/wallets/walletConnectors/chunk-2NHQTZGS.js +276 -0
- package/dist/wallets/walletConnectors/chunk-4Q7XTNTE.js +63 -0
- package/dist/wallets/walletConnectors/chunk-4SCX34NL.js +276 -0
- package/dist/wallets/walletConnectors/chunk-B6GPEHW7.js +47 -0
- package/dist/wallets/walletConnectors/chunk-CZ7WCJW5.js +63 -0
- package/dist/wallets/walletConnectors/chunk-DNSC37SU.js +47 -0
- package/dist/wallets/walletConnectors/chunk-EN5R4RRF.js +47 -0
- package/dist/wallets/walletConnectors/chunk-FCRLSDVW.js +513 -0
- package/dist/wallets/walletConnectors/chunk-FLCBPO5T.js +276 -0
- package/dist/wallets/walletConnectors/chunk-HIRSPIIU.js +1760 -0
- package/dist/wallets/walletConnectors/chunk-JKDAQWPW.js +47 -0
- package/dist/wallets/walletConnectors/chunk-K42FR6F7.js +513 -0
- package/dist/wallets/walletConnectors/chunk-K7WCM7JL.js +513 -0
- package/dist/wallets/walletConnectors/chunk-L2ICV2P2.js +276 -0
- package/dist/wallets/walletConnectors/chunk-MOQSXFIP.js +47 -0
- package/dist/wallets/walletConnectors/chunk-MSK4NN2E.js +47 -0
- package/dist/wallets/walletConnectors/chunk-PE6CXY5F.js +513 -0
- package/dist/wallets/walletConnectors/chunk-PQDQUIIL.js +276 -0
- package/dist/wallets/walletConnectors/chunk-QOZL4BMA.js +513 -0
- package/dist/wallets/walletConnectors/chunk-RWJX5CRR.js +276 -0
- package/dist/wallets/walletConnectors/chunk-S6LSALLS.js +47 -0
- package/dist/wallets/walletConnectors/chunk-UX4IUIRD.js +515 -0
- package/dist/wallets/walletConnectors/chunk-WCHG2Q2N.js +276 -0
- package/dist/wallets/walletConnectors/chunk-XKNVF62K.js +276 -0
- package/dist/wallets/walletConnectors/chunk-Z2IWGNDA.js +515 -0
- package/dist/wallets/walletConnectors/chunk-Z34L5C76.js +1760 -0
- package/dist/wallets/walletConnectors/index.js +51 -51
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
isTestnet,
|
|
31
31
|
networkToChainId,
|
|
32
32
|
networks_exports
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-GG57EUYL.js";
|
|
34
34
|
import "./chunk-DFWCI4QG.js";
|
|
35
35
|
import {
|
|
36
36
|
darkTheme
|
|
@@ -2895,7 +2895,32 @@ function PinInputModal({
|
|
|
2895
2895
|
disabled: isLoading
|
|
2896
2896
|
},
|
|
2897
2897
|
num
|
|
2898
|
-
)), /* @__PURE__ */ React14.createElement(
|
|
2898
|
+
)), /* @__PURE__ */ React14.createElement(
|
|
2899
|
+
"button",
|
|
2900
|
+
{
|
|
2901
|
+
type: "button",
|
|
2902
|
+
className: keypadButton,
|
|
2903
|
+
onClick: () => setPin(""),
|
|
2904
|
+
disabled: isLoading || pin.length === 0,
|
|
2905
|
+
"aria-label": "Clear all"
|
|
2906
|
+
},
|
|
2907
|
+
/* @__PURE__ */ React14.createElement(
|
|
2908
|
+
"svg",
|
|
2909
|
+
{
|
|
2910
|
+
viewBox: "0 0 24 24",
|
|
2911
|
+
fill: "none",
|
|
2912
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2913
|
+
},
|
|
2914
|
+
/* @__PURE__ */ React14.createElement("title", null, "Clear all"),
|
|
2915
|
+
/* @__PURE__ */ React14.createElement(
|
|
2916
|
+
"path",
|
|
2917
|
+
{
|
|
2918
|
+
d: "M17.65 6.35C16.2 4.9 14.21 4 12 4C7.58 4 4.01 7.58 4.01 12C4.01 16.42 7.58 20 12 20C15.73 20 18.84 17.45 19.73 14H17.65C16.83 16.33 14.61 18 12 18C8.69 18 6 15.31 6 12C6 8.69 8.69 6 12 6C13.66 6 15.14 6.69 16.22 7.78L13 11H20V4L17.65 6.35Z",
|
|
2919
|
+
fill: "currentColor"
|
|
2920
|
+
}
|
|
2921
|
+
)
|
|
2922
|
+
)
|
|
2923
|
+
), /* @__PURE__ */ React14.createElement(
|
|
2899
2924
|
"button",
|
|
2900
2925
|
{
|
|
2901
2926
|
key: keypadNumbers[9],
|
|
@@ -2911,7 +2936,7 @@ function PinInputModal({
|
|
|
2911
2936
|
type: "button",
|
|
2912
2937
|
className: keypadButton,
|
|
2913
2938
|
onClick: () => setPin(pin.slice(0, -1)),
|
|
2914
|
-
disabled: isLoading,
|
|
2939
|
+
disabled: isLoading || pin.length === 0,
|
|
2915
2940
|
"aria-label": "Delete"
|
|
2916
2941
|
},
|
|
2917
2942
|
/* @__PURE__ */ React14.createElement(
|
|
@@ -3213,7 +3238,7 @@ function setRainbowKitVersion({ version }) {
|
|
|
3213
3238
|
}
|
|
3214
3239
|
function useFingerprint() {
|
|
3215
3240
|
const fingerprint = useCallback4(() => {
|
|
3216
|
-
setRainbowKitVersion({ version: "2.4.
|
|
3241
|
+
setRainbowKitVersion({ version: "2.4.13" });
|
|
3217
3242
|
}, []);
|
|
3218
3243
|
useEffect12(() => {
|
|
3219
3244
|
fingerprint();
|
|
@@ -12616,7 +12641,7 @@ function useBitcoinWallet() {
|
|
|
12616
12641
|
});
|
|
12617
12642
|
return;
|
|
12618
12643
|
}
|
|
12619
|
-
const { AbcBitcoinProvider, createAbcWaasApiClient: createAbcWaasApiClient2 } = await import("./abcWallet-
|
|
12644
|
+
const { AbcBitcoinProvider, createAbcWaasApiClient: createAbcWaasApiClient2 } = await import("./abcWallet-NTVWBYWF.js");
|
|
12620
12645
|
const client = createAbcWaasApiClient2({
|
|
12621
12646
|
waasUrl: process.env.NEXT_PUBLIC_ABC_WAAS_URL || "",
|
|
12622
12647
|
plain: "",
|
|
@@ -12677,11 +12702,22 @@ function useBitcoinWallet() {
|
|
|
12677
12702
|
|
|
12678
12703
|
// src/hooks/useSolanaWallet.ts
|
|
12679
12704
|
import { useWallet as useWallet5 } from "@solana/wallet-adapter-react";
|
|
12680
|
-
import { useEffect as useEffect31, useState as useState35 } from "react";
|
|
12705
|
+
import { useCallback as useCallback19, useEffect as useEffect31, useState as useState35 } from "react";
|
|
12681
12706
|
import { useAccount as useAccount22 } from "wagmi";
|
|
12682
12707
|
function useSolanaWallet() {
|
|
12683
12708
|
const { isConnected: evmConnected, connector } = useAccount22();
|
|
12684
|
-
const
|
|
12709
|
+
const requestPin = useCallback19(
|
|
12710
|
+
async (purpose = "transaction") => {
|
|
12711
|
+
const globalRequestPin = window.__TALKENKIT_REQUEST_PIN__;
|
|
12712
|
+
if (typeof globalRequestPin === "function") {
|
|
12713
|
+
return globalRequestPin(purpose);
|
|
12714
|
+
}
|
|
12715
|
+
throw new Error(
|
|
12716
|
+
"PIN provider not available. Ensure RainbowKitProvider is configured correctly."
|
|
12717
|
+
);
|
|
12718
|
+
},
|
|
12719
|
+
[]
|
|
12720
|
+
);
|
|
12685
12721
|
const externalWallet = useWallet5();
|
|
12686
12722
|
const [windowSolanaState, setWindowSolanaState] = useState35({
|
|
12687
12723
|
connected: false,
|
|
@@ -12734,7 +12770,7 @@ function useSolanaWallet() {
|
|
|
12734
12770
|
});
|
|
12735
12771
|
return;
|
|
12736
12772
|
}
|
|
12737
|
-
const { AbcSolanaProvider, createAbcWaasApiClient: createAbcWaasApiClient2 } = await import("./abcWallet-
|
|
12773
|
+
const { AbcSolanaProvider, createAbcWaasApiClient: createAbcWaasApiClient2 } = await import("./abcWallet-NTVWBYWF.js");
|
|
12738
12774
|
const client = createAbcWaasApiClient2({
|
|
12739
12775
|
waasUrl: process.env.NEXT_PUBLIC_ABC_WAAS_URL || "",
|
|
12740
12776
|
plain: "",
|
|
@@ -176,6 +176,14 @@ export declare class AbcWaasClient {
|
|
|
176
176
|
value?: string;
|
|
177
177
|
data?: string;
|
|
178
178
|
}): Promise<string>;
|
|
179
|
+
/**
|
|
180
|
+
* Get transaction count (nonce)
|
|
181
|
+
* Reference: ABC WaaS API - /wapi/v2/transactions/count
|
|
182
|
+
*/
|
|
183
|
+
getTransactionCount(params: {
|
|
184
|
+
chainId: number;
|
|
185
|
+
address: string;
|
|
186
|
+
}): Promise<string>;
|
|
179
187
|
/**
|
|
180
188
|
* Get wallet info
|
|
181
189
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
abcConnector
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-PQDQUIIL.js";
|
|
5
|
+
import "../chunk-UX4IUIRD.js";
|
|
6
|
+
import "../chunk-Z34L5C76.js";
|
|
7
7
|
import "../chunk-4PCVQBFZ.js";
|
|
8
8
|
import "../chunk-NDYGTKP5.js";
|
|
9
9
|
import "../chunk-A7FIBI6X.js";
|
|
@@ -95,6 +95,10 @@ export declare class AbcEvmProvider extends EventEmitter {
|
|
|
95
95
|
* Add Ethereum chain
|
|
96
96
|
*/
|
|
97
97
|
private wallet_addEthereumChain;
|
|
98
|
+
/**
|
|
99
|
+
* Get transaction count (nonce) using ABC WaaS API
|
|
100
|
+
*/
|
|
101
|
+
private eth_getTransactionCount;
|
|
98
102
|
/**
|
|
99
103
|
* Estimate gas for transaction
|
|
100
104
|
* Uses ABC WaaS gas estimation API with fallback
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
abcWallet
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-MOQSXFIP.js";
|
|
5
|
+
import "../chunk-PQDQUIIL.js";
|
|
6
|
+
import "../chunk-UX4IUIRD.js";
|
|
7
|
+
import "../chunk-Z34L5C76.js";
|
|
8
8
|
import "../chunk-4PCVQBFZ.js";
|
|
9
9
|
import "../chunk-NDYGTKP5.js";
|
|
10
10
|
import "../chunk-A7FIBI6X.js";
|
|
@@ -39,19 +39,19 @@ import "../chunk-KXEAFXAA.js";
|
|
|
39
39
|
import "../chunk-MPFE6GP2.js";
|
|
40
40
|
import {
|
|
41
41
|
abcWallet
|
|
42
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-MOQSXFIP.js";
|
|
43
43
|
import {
|
|
44
44
|
abcConnector
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-PQDQUIIL.js";
|
|
46
46
|
import {
|
|
47
47
|
AbcEvmProvider,
|
|
48
48
|
createAbcEvmProvider,
|
|
49
49
|
createAbcProvider
|
|
50
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-UX4IUIRD.js";
|
|
51
51
|
import {
|
|
52
52
|
AbcWaasClient,
|
|
53
53
|
createAbcWaasClient
|
|
54
|
-
} from "../chunk-
|
|
54
|
+
} from "../chunk-Z34L5C76.js";
|
|
55
55
|
import "../chunk-4PCVQBFZ.js";
|
|
56
56
|
import {
|
|
57
57
|
secure_default
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
abcConnector
|
|
4
|
+
} from "./chunk-2NHQTZGS.js";
|
|
5
|
+
import {
|
|
6
|
+
ABC_WALLET_METADATA
|
|
7
|
+
} from "./chunk-VETRBBA2.js";
|
|
8
|
+
|
|
9
|
+
// src/wallets/walletConnectors/abcWallet/abcWallet.ts
|
|
10
|
+
var abcWallet = (specificOptions) => ({ projectId }) => {
|
|
11
|
+
const waasUrl = specificOptions?.waasUrl || process.env.NEXT_PUBLIC_ABC_WAAS_URL || process.env.VITE_ABC_WAAS_URL;
|
|
12
|
+
if (!waasUrl) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
'ABC WaaS URL is required. Please provide it via:\n1. abcWallet({ waasUrl: "..." }) options, or\n2. NEXT_PUBLIC_ABC_WAAS_URL environment variable, or\n3. VITE_ABC_WAAS_URL environment variable'
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
const config = {
|
|
18
|
+
waasUrl,
|
|
19
|
+
apiKey: specificOptions?.apiKey,
|
|
20
|
+
plain: specificOptions?.plain || "",
|
|
21
|
+
// Deprecated - not used (secure.ts uses random generation)
|
|
22
|
+
environment: specificOptions?.environment || "development",
|
|
23
|
+
defaultChainId: specificOptions?.defaultChainId,
|
|
24
|
+
defaultSolanaNetwork: specificOptions?.defaultSolanaNetwork,
|
|
25
|
+
defaultBitcoinNetwork: specificOptions?.defaultBitcoinNetwork,
|
|
26
|
+
projectId
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
id: ABC_WALLET_METADATA.id,
|
|
30
|
+
name: ABC_WALLET_METADATA.name,
|
|
31
|
+
rdns: ABC_WALLET_METADATA.rdns,
|
|
32
|
+
iconUrl: async () => (await import("./abcWallet-AYWSIGAG.js")).default,
|
|
33
|
+
iconBackground: ABC_WALLET_METADATA.iconBackground,
|
|
34
|
+
// Embedded wallet - no installation required
|
|
35
|
+
installed: void 0,
|
|
36
|
+
// No download URLs for embedded wallet
|
|
37
|
+
downloadUrls: void 0,
|
|
38
|
+
// Create connector - wrapper function required by Wallet type
|
|
39
|
+
createConnector: (_walletDetails) => abcConnector({ config }),
|
|
40
|
+
// Embedded wallet always available
|
|
41
|
+
hidden: () => false
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
abcWallet
|
|
47
|
+
};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
createAbcEvmProvider
|
|
4
|
+
} from "./chunk-Z2IWGNDA.js";
|
|
5
|
+
import {
|
|
6
|
+
createAbcWaasClient
|
|
7
|
+
} from "./chunk-HIRSPIIU.js";
|
|
8
|
+
import {
|
|
9
|
+
setGlobalDefaultBitcoinNetwork,
|
|
10
|
+
setGlobalDefaultChainId,
|
|
11
|
+
setGlobalDefaultSolanaNetwork
|
|
12
|
+
} from "./chunk-A7FIBI6X.js";
|
|
13
|
+
import {
|
|
14
|
+
clearAuthState,
|
|
15
|
+
clearEncryptedTokens,
|
|
16
|
+
clearStorage,
|
|
17
|
+
loadAuthState,
|
|
18
|
+
loadFromStorage,
|
|
19
|
+
saveAuthState
|
|
20
|
+
} from "./chunk-TYUEB4VT.js";
|
|
21
|
+
|
|
22
|
+
// src/wallets/walletConnectors/abcWallet/abcConnector.ts
|
|
23
|
+
import { createConnector } from "wagmi";
|
|
24
|
+
function abcConnector(options) {
|
|
25
|
+
const { config } = options;
|
|
26
|
+
if (config.defaultChainId) {
|
|
27
|
+
setGlobalDefaultChainId(config.defaultChainId);
|
|
28
|
+
}
|
|
29
|
+
if (config.defaultSolanaNetwork) {
|
|
30
|
+
setGlobalDefaultSolanaNetwork(config.defaultSolanaNetwork);
|
|
31
|
+
}
|
|
32
|
+
if (config.defaultBitcoinNetwork) {
|
|
33
|
+
setGlobalDefaultBitcoinNetwork(config.defaultBitcoinNetwork);
|
|
34
|
+
}
|
|
35
|
+
return createConnector((wagmiConfig) => {
|
|
36
|
+
const client = createAbcWaasClient(config);
|
|
37
|
+
const provider = createAbcEvmProvider(client);
|
|
38
|
+
let accountsChangedHandler;
|
|
39
|
+
let chainChangedHandler;
|
|
40
|
+
let disconnectHandler;
|
|
41
|
+
return {
|
|
42
|
+
id: "abc",
|
|
43
|
+
name: "ABC Wallet",
|
|
44
|
+
type: "abc",
|
|
45
|
+
/**
|
|
46
|
+
* Connect wallet
|
|
47
|
+
*/
|
|
48
|
+
async connect() {
|
|
49
|
+
try {
|
|
50
|
+
const authState = loadAuthState();
|
|
51
|
+
if (!authState || !authState.isAuthenticated || !authState.wallet) {
|
|
52
|
+
throw new Error("ABC_LOGIN_REQUIRED");
|
|
53
|
+
}
|
|
54
|
+
provider.setWallet(authState.wallet);
|
|
55
|
+
if (authState.accessToken && authState.refreshToken && authState.expiresAt) {
|
|
56
|
+
client.setTokens(
|
|
57
|
+
authState.accessToken,
|
|
58
|
+
authState.refreshToken,
|
|
59
|
+
authState.expiresAt
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const accounts = await provider.request({
|
|
63
|
+
method: "eth_requestAccounts"
|
|
64
|
+
});
|
|
65
|
+
const currentChainId = await provider.request({
|
|
66
|
+
method: "eth_chainId"
|
|
67
|
+
});
|
|
68
|
+
if (accountsChangedHandler) {
|
|
69
|
+
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
70
|
+
}
|
|
71
|
+
accountsChangedHandler = (accounts2) => {
|
|
72
|
+
wagmiConfig.emitter.emit("change", {
|
|
73
|
+
accounts: accounts2
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
provider.on("accountsChanged", accountsChangedHandler);
|
|
77
|
+
if (chainChangedHandler) {
|
|
78
|
+
provider.removeListener("chainChanged", chainChangedHandler);
|
|
79
|
+
}
|
|
80
|
+
chainChangedHandler = (chainId) => {
|
|
81
|
+
wagmiConfig.emitter.emit("change", {
|
|
82
|
+
chainId: Number(chainId)
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
provider.on("chainChanged", chainChangedHandler);
|
|
86
|
+
if (disconnectHandler) {
|
|
87
|
+
provider.removeListener("disconnect", disconnectHandler);
|
|
88
|
+
}
|
|
89
|
+
disconnectHandler = () => {
|
|
90
|
+
wagmiConfig.emitter.emit("disconnect");
|
|
91
|
+
this.onDisconnect();
|
|
92
|
+
};
|
|
93
|
+
provider.on("disconnect", disconnectHandler);
|
|
94
|
+
wagmiConfig.emitter.emit("connect", {
|
|
95
|
+
accounts,
|
|
96
|
+
chainId: Number(currentChainId)
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
accounts,
|
|
100
|
+
chainId: Number(currentChainId)
|
|
101
|
+
};
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error("\u274C ABC Connector connect() failed:", {
|
|
104
|
+
message: error.message,
|
|
105
|
+
code: error.code,
|
|
106
|
+
error
|
|
107
|
+
});
|
|
108
|
+
if (error.message === "ABC_LOGIN_REQUIRED") {
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
/**
|
|
115
|
+
* Disconnect wallet
|
|
116
|
+
*/
|
|
117
|
+
async disconnect() {
|
|
118
|
+
if (accountsChangedHandler) {
|
|
119
|
+
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
120
|
+
accountsChangedHandler = void 0;
|
|
121
|
+
}
|
|
122
|
+
if (chainChangedHandler) {
|
|
123
|
+
provider.removeListener("chainChanged", chainChangedHandler);
|
|
124
|
+
chainChangedHandler = void 0;
|
|
125
|
+
}
|
|
126
|
+
if (disconnectHandler) {
|
|
127
|
+
provider.removeListener("disconnect", disconnectHandler);
|
|
128
|
+
disconnectHandler = void 0;
|
|
129
|
+
}
|
|
130
|
+
provider.clearWallet();
|
|
131
|
+
await client.logout();
|
|
132
|
+
let savedPinHash = null;
|
|
133
|
+
let savedEmail = null;
|
|
134
|
+
if (typeof window !== "undefined") {
|
|
135
|
+
savedPinHash = localStorage.getItem("talkenkit_abc_pin_hash");
|
|
136
|
+
savedEmail = localStorage.getItem("talkenkit_abc_saved_email");
|
|
137
|
+
}
|
|
138
|
+
clearAuthState();
|
|
139
|
+
clearEncryptedTokens();
|
|
140
|
+
if (typeof window !== "undefined") {
|
|
141
|
+
localStorage.removeItem("talkenkit_abc_enc_salt");
|
|
142
|
+
localStorage.removeItem("talkenkit_abc_enc_tokens");
|
|
143
|
+
if (savedPinHash) {
|
|
144
|
+
localStorage.setItem("talkenkit_abc_pin_hash", savedPinHash);
|
|
145
|
+
}
|
|
146
|
+
if (savedEmail) {
|
|
147
|
+
localStorage.setItem("talkenkit_abc_saved_email", savedEmail);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
console.log("\u2705 ABC Wallet disconnected (PIN preserved)");
|
|
151
|
+
},
|
|
152
|
+
/**
|
|
153
|
+
* Get accounts
|
|
154
|
+
*/
|
|
155
|
+
async getAccounts() {
|
|
156
|
+
const accounts = await provider.request({
|
|
157
|
+
method: "eth_accounts"
|
|
158
|
+
});
|
|
159
|
+
return accounts.map((account) => account);
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* Get chain ID
|
|
163
|
+
*/
|
|
164
|
+
async getChainId() {
|
|
165
|
+
const chainId = await provider.request({
|
|
166
|
+
method: "eth_chainId"
|
|
167
|
+
});
|
|
168
|
+
return Number(chainId);
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* Get provider
|
|
172
|
+
*/
|
|
173
|
+
async getProvider() {
|
|
174
|
+
return provider;
|
|
175
|
+
},
|
|
176
|
+
/**
|
|
177
|
+
* Check if authorized (has valid session)
|
|
178
|
+
* Auto-refreshes access token if expired but refresh token is valid
|
|
179
|
+
*/
|
|
180
|
+
async isAuthorized() {
|
|
181
|
+
try {
|
|
182
|
+
const authState = loadAuthState();
|
|
183
|
+
if (!authState || !authState.isAuthenticated) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
if (!authState.wallet) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
if (client.isAuthenticated()) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
const refreshToken = loadFromStorage(
|
|
193
|
+
"refresh_token" /* REFRESH_TOKEN */
|
|
194
|
+
);
|
|
195
|
+
if (!refreshToken) {
|
|
196
|
+
clearStorage();
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
await client.refreshTokens(refreshToken);
|
|
201
|
+
const updatedState = loadAuthState();
|
|
202
|
+
return updatedState?.isAuthenticated ?? false;
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error("[AbcConnector] Token refresh failed:", error);
|
|
205
|
+
clearStorage();
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.error(
|
|
210
|
+
"[AbcConnector] Unexpected error in isAuthorized:",
|
|
211
|
+
error
|
|
212
|
+
);
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* Switch chain
|
|
218
|
+
*/
|
|
219
|
+
async switchChain({ chainId }) {
|
|
220
|
+
await provider.request({
|
|
221
|
+
method: "wallet_switchEthereumChain",
|
|
222
|
+
params: [{ chainId: `0x${chainId.toString(16)}` }]
|
|
223
|
+
});
|
|
224
|
+
const newChainId = await this.getChainId();
|
|
225
|
+
const authState = loadAuthState();
|
|
226
|
+
if (authState?.wallet) {
|
|
227
|
+
authState.wallet.chainId = newChainId;
|
|
228
|
+
saveAuthState(authState);
|
|
229
|
+
}
|
|
230
|
+
return wagmiConfig.chains.find((x) => x.id === chainId) ?? {
|
|
231
|
+
id: chainId,
|
|
232
|
+
name: `Chain ${chainId}`,
|
|
233
|
+
nativeCurrency: {
|
|
234
|
+
name: "Ether",
|
|
235
|
+
decimals: 18,
|
|
236
|
+
symbol: "ETH"
|
|
237
|
+
},
|
|
238
|
+
rpcUrls: {
|
|
239
|
+
default: { http: [""] }
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Handle accounts changed
|
|
245
|
+
*/
|
|
246
|
+
onAccountsChanged(accounts) {
|
|
247
|
+
if (accounts.length === 0) {
|
|
248
|
+
this.onDisconnect();
|
|
249
|
+
} else {
|
|
250
|
+
wagmiConfig.emitter.emit("change", {
|
|
251
|
+
accounts
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* Handle chain changed
|
|
257
|
+
*/
|
|
258
|
+
onChainChanged(chain) {
|
|
259
|
+
const chainId = Number(chain);
|
|
260
|
+
wagmiConfig.emitter.emit("change", { chainId });
|
|
261
|
+
},
|
|
262
|
+
/**
|
|
263
|
+
* Handle disconnect
|
|
264
|
+
*/
|
|
265
|
+
onDisconnect(_error) {
|
|
266
|
+
provider.clearWallet();
|
|
267
|
+
clearAuthState();
|
|
268
|
+
wagmiConfig.emitter.emit("disconnect");
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export {
|
|
275
|
+
abcConnector
|
|
276
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
TransactionApi
|
|
4
|
+
} from "./chunk-B56IHEUP.js";
|
|
5
|
+
import {
|
|
6
|
+
WalletApi
|
|
7
|
+
} from "./chunk-MPNSYA4E.js";
|
|
8
|
+
import {
|
|
9
|
+
BitcoinApi
|
|
10
|
+
} from "./chunk-KB7OGAUC.js";
|
|
11
|
+
import {
|
|
12
|
+
AuthApi
|
|
13
|
+
} from "./chunk-QCIIXMAZ.js";
|
|
14
|
+
import {
|
|
15
|
+
SigningApi
|
|
16
|
+
} from "./chunk-2HAU36T2.js";
|
|
17
|
+
import {
|
|
18
|
+
SolanaApi
|
|
19
|
+
} from "./chunk-XKGUE56S.js";
|
|
20
|
+
|
|
21
|
+
// src/wallets/walletConnectors/abcWallet/api/index.ts
|
|
22
|
+
var AbcWaasApiClient = class {
|
|
23
|
+
constructor(config) {
|
|
24
|
+
this.auth = new AuthApi(config);
|
|
25
|
+
this.wallet = new WalletApi(config);
|
|
26
|
+
this.transaction = new TransactionApi(config);
|
|
27
|
+
this.signing = new SigningApi(config);
|
|
28
|
+
this.solana = new SolanaApi(config);
|
|
29
|
+
this.bitcoin = new BitcoinApi(config);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check if user is authenticated
|
|
33
|
+
*/
|
|
34
|
+
isAuthenticated() {
|
|
35
|
+
return this.auth.isAuthenticated();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if access token is expired
|
|
39
|
+
*/
|
|
40
|
+
isTokenExpired() {
|
|
41
|
+
return this.auth.isTokenExpired();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get current access token
|
|
45
|
+
*/
|
|
46
|
+
getAccessToken() {
|
|
47
|
+
return this.auth.getAccessToken();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Logout (clear tokens)
|
|
51
|
+
*/
|
|
52
|
+
async logout() {
|
|
53
|
+
await this.auth.logout();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
function createAbcWaasApiClient(config) {
|
|
57
|
+
return new AbcWaasApiClient(config);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
AbcWaasApiClient,
|
|
62
|
+
createAbcWaasApiClient
|
|
63
|
+
};
|