@aintivirus-ai/mixer-sdk 1.0.0

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.
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * Hook for deploying mixers (EVM or Solana)
4
+ * Use this hook when you need to deploy new mixer instances
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useDeploy = useDeploy;
8
+ const react_1 = require("react");
9
+ const types_1 = require("../types");
10
+ const evm_1 = require("../evm");
11
+ const solana_1 = require("../solana");
12
+ const wagmi_1 = require("wagmi");
13
+ const utils_1 = require("./utils");
14
+ /**
15
+ * Hook for deploying mixers
16
+ * Only initializes what's needed for deployment
17
+ */
18
+ function useDeploy(config) {
19
+ // EVM setup
20
+ const { isConnected: evmConnected } = (0, wagmi_1.useAccount)();
21
+ const { data: walletClient } = (0, wagmi_1.useWalletClient)();
22
+ const publicClient = (0, wagmi_1.usePublicClient)();
23
+ const evmSDK = (0, react_1.useMemo)(() => {
24
+ if (!config.evm?.factoryAddress) {
25
+ return null;
26
+ }
27
+ if (!publicClient) {
28
+ return null;
29
+ }
30
+ try {
31
+ const provider = (0, utils_1.createEthersProviderFromViem)(publicClient);
32
+ const signerOrProvider = walletClient
33
+ ? (0, utils_1.createEthersSignerFromViem)(walletClient, publicClient)
34
+ : provider;
35
+ return new evm_1.AintiVirusEVM(config.evm.factoryAddress, config.evm.tokenAddress || "0x0000000000000000000000000000000000000000", signerOrProvider);
36
+ }
37
+ catch (error) {
38
+ console.error("Failed to initialize AintiVirusEVM:", error);
39
+ return null;
40
+ }
41
+ }, [
42
+ config.evm?.factoryAddress,
43
+ config.evm?.tokenAddress,
44
+ walletClient,
45
+ publicClient,
46
+ ]);
47
+ const isEVMReady = !!evmSDK && evmConnected;
48
+ // Solana setup
49
+ const solanaSDK = (0, react_1.useMemo)(() => {
50
+ if (!config.solana?.factoryProgramId ||
51
+ !config.solana?.mixerProgramId ||
52
+ !config.solana?.stakingProgramId) {
53
+ return null;
54
+ }
55
+ if (!config.solanaWallet || !config.solanaConnection) {
56
+ return null;
57
+ }
58
+ try {
59
+ return new solana_1.AintiVirusSolana(config.solana.factoryProgramId, config.solana.mixerProgramId, config.solana.stakingProgramId, config.solanaWallet, config.solanaConnection, config.solana.tokenMint);
60
+ }
61
+ catch (error) {
62
+ console.error("Failed to initialize AintiVirusSolana:", error);
63
+ return null;
64
+ }
65
+ }, [
66
+ config.solana?.factoryProgramId,
67
+ config.solana?.mixerProgramId,
68
+ config.solana?.stakingProgramId,
69
+ config.solana?.tokenMint,
70
+ config.solanaWallet,
71
+ config.solanaConnection,
72
+ ]);
73
+ const isSolanaReady = !!solanaSDK && !!config.solanaWallet?.publicKey;
74
+ // Deploy mixer function
75
+ const deployMixer = (0, react_1.useCallback)(async (chainType, mode, amount) => {
76
+ if (chainType === types_1.ChainType.EVM) {
77
+ if (!evmSDK) {
78
+ throw new Error("EVM SDK not initialized");
79
+ }
80
+ return evmSDK.deployMixer(mode, amount);
81
+ }
82
+ else if (chainType === types_1.ChainType.SOLANA) {
83
+ if (!solanaSDK) {
84
+ throw new Error("Solana SDK not initialized");
85
+ }
86
+ const result = await solanaSDK.deployMixer(mode, amount);
87
+ return result;
88
+ }
89
+ throw new Error(`Unsupported chain type: ${chainType}`);
90
+ }, [evmSDK, solanaSDK]);
91
+ return {
92
+ deployMixer,
93
+ isEVMReady,
94
+ isSolanaReady,
95
+ };
96
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Hook for depositing (EVM or Solana)
3
+ * Use this hook when you only need deposit functionality
4
+ */
5
+ import { ChainType, EVMHookConfig, SolanaHookConfig } from "../types";
6
+ import { Wallet } from "@coral-xyz/anchor";
7
+ import { Connection } from "@solana/web3.js";
8
+ import { TransactionResult } from "../types";
9
+ /**
10
+ * Hook configuration for deposit
11
+ */
12
+ export interface DepositHookConfig {
13
+ evm?: EVMHookConfig;
14
+ solana?: SolanaHookConfig;
15
+ solanaWallet?: Wallet;
16
+ solanaConnection?: Connection;
17
+ }
18
+ /**
19
+ * Deposit hook return type
20
+ */
21
+ export interface UseDepositReturn {
22
+ deposit: (chainType: ChainType, amount: bigint, commitment: bigint) => Promise<TransactionResult>;
23
+ isEVMReady: boolean;
24
+ isSolanaReady: boolean;
25
+ }
26
+ /**
27
+ * Hook for depositing funds
28
+ * Only initializes what's needed for deposits
29
+ */
30
+ export declare function useDeposit(config: DepositHookConfig): UseDepositReturn;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * Hook for depositing (EVM or Solana)
4
+ * Use this hook when you only need deposit functionality
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useDeposit = useDeposit;
8
+ const react_1 = require("react");
9
+ const types_1 = require("../types");
10
+ const evm_1 = require("../evm");
11
+ const solana_1 = require("../solana");
12
+ const wagmi_1 = require("wagmi");
13
+ const utils_1 = require("./utils");
14
+ /**
15
+ * Hook for depositing funds
16
+ * Only initializes what's needed for deposits
17
+ */
18
+ function useDeposit(config) {
19
+ // EVM setup (only if EVM config provided)
20
+ const { isConnected: evmConnected } = (0, wagmi_1.useAccount)();
21
+ const { data: walletClient } = (0, wagmi_1.useWalletClient)();
22
+ const publicClient = (0, wagmi_1.usePublicClient)();
23
+ const evmSDK = (0, react_1.useMemo)(() => {
24
+ if (!config.evm?.factoryAddress) {
25
+ return null;
26
+ }
27
+ if (!publicClient) {
28
+ return null;
29
+ }
30
+ try {
31
+ const provider = (0, utils_1.createEthersProviderFromViem)(publicClient);
32
+ const signerOrProvider = walletClient
33
+ ? (0, utils_1.createEthersSignerFromViem)(walletClient, publicClient)
34
+ : provider;
35
+ return new evm_1.AintiVirusEVM(config.evm.factoryAddress, config.evm.tokenAddress || "0x0000000000000000000000000000000000000000", // Default to zero address if not provided
36
+ signerOrProvider);
37
+ }
38
+ catch (error) {
39
+ console.error("Failed to initialize AintiVirusEVM:", error);
40
+ return null;
41
+ }
42
+ }, [
43
+ config.evm?.factoryAddress,
44
+ config.evm?.tokenAddress,
45
+ walletClient,
46
+ publicClient,
47
+ ]);
48
+ const isEVMReady = !!evmSDK && evmConnected;
49
+ // Solana setup (only if Solana config provided)
50
+ const solanaSDK = (0, react_1.useMemo)(() => {
51
+ if (!config.solana?.factoryProgramId ||
52
+ !config.solana?.mixerProgramId ||
53
+ !config.solana?.stakingProgramId) {
54
+ return null;
55
+ }
56
+ if (!config.solanaWallet || !config.solanaConnection) {
57
+ return null;
58
+ }
59
+ try {
60
+ return new solana_1.AintiVirusSolana(config.solana.factoryProgramId, config.solana.mixerProgramId, config.solana.stakingProgramId, config.solanaWallet, config.solanaConnection, config.solana.tokenMint);
61
+ }
62
+ catch (error) {
63
+ console.error("Failed to initialize AintiVirusSolana:", error);
64
+ return null;
65
+ }
66
+ }, [
67
+ config.solana?.factoryProgramId,
68
+ config.solana?.mixerProgramId,
69
+ config.solana?.stakingProgramId,
70
+ config.solana?.tokenMint,
71
+ config.solanaWallet,
72
+ config.solanaConnection,
73
+ ]);
74
+ const isSolanaReady = !!solanaSDK && !!config.solanaWallet?.publicKey;
75
+ // Deposit function
76
+ const deposit = (0, react_1.useCallback)(async (chainType, amount, commitment) => {
77
+ if (chainType === types_1.ChainType.EVM) {
78
+ if (!evmSDK) {
79
+ throw new Error("EVM SDK not initialized");
80
+ }
81
+ return evmSDK.depositEth(amount, commitment);
82
+ }
83
+ else if (chainType === types_1.ChainType.SOLANA) {
84
+ if (!solanaSDK) {
85
+ throw new Error("Solana SDK not initialized");
86
+ }
87
+ return solanaSDK.depositSol(amount, commitment);
88
+ }
89
+ throw new Error(`Unsupported chain type: ${chainType}`);
90
+ }, [evmSDK, solanaSDK]);
91
+ return {
92
+ deposit,
93
+ isEVMReady,
94
+ isSolanaReady,
95
+ };
96
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Hook for staking (EVM or Solana)
3
+ * Use this hook when you only need staking functionality
4
+ */
5
+ import { ChainType, EVMHookConfig, SolanaHookConfig } from "../types";
6
+ import { Wallet } from "@coral-xyz/anchor";
7
+ import { Connection } from "@solana/web3.js";
8
+ import { TransactionResult } from "../types";
9
+ /**
10
+ * Hook configuration for staking
11
+ */
12
+ export interface StakeHookConfig {
13
+ evm?: EVMHookConfig;
14
+ solana?: SolanaHookConfig;
15
+ solanaWallet?: Wallet;
16
+ solanaConnection?: Connection;
17
+ }
18
+ /**
19
+ * Staking hook return type
20
+ */
21
+ export interface UseStakeReturn {
22
+ stake: (chainType: ChainType, amount: bigint) => Promise<TransactionResult>;
23
+ unstake: (chainType: ChainType) => Promise<TransactionResult>;
24
+ isEVMReady: boolean;
25
+ isSolanaReady: boolean;
26
+ }
27
+ /**
28
+ * Hook for staking/unstaking funds
29
+ * Only initializes what's needed for staking
30
+ */
31
+ export declare function useStake(config: StakeHookConfig): UseStakeReturn;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ /**
3
+ * Hook for staking (EVM or Solana)
4
+ * Use this hook when you only need staking functionality
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useStake = useStake;
8
+ const react_1 = require("react");
9
+ const types_1 = require("../types");
10
+ const evm_1 = require("../evm");
11
+ const solana_1 = require("../solana");
12
+ const wagmi_1 = require("wagmi");
13
+ const utils_1 = require("./utils");
14
+ /**
15
+ * Hook for staking/unstaking funds
16
+ * Only initializes what's needed for staking
17
+ */
18
+ function useStake(config) {
19
+ // EVM setup
20
+ const { isConnected: evmConnected } = (0, wagmi_1.useAccount)();
21
+ const { data: walletClient } = (0, wagmi_1.useWalletClient)();
22
+ const publicClient = (0, wagmi_1.usePublicClient)();
23
+ const evmSDK = (0, react_1.useMemo)(() => {
24
+ if (!config.evm?.factoryAddress) {
25
+ return null;
26
+ }
27
+ if (!publicClient) {
28
+ return null;
29
+ }
30
+ try {
31
+ const provider = (0, utils_1.createEthersProviderFromViem)(publicClient);
32
+ const signerOrProvider = walletClient
33
+ ? (0, utils_1.createEthersSignerFromViem)(walletClient, publicClient)
34
+ : provider;
35
+ return new evm_1.AintiVirusEVM(config.evm.factoryAddress, config.evm.tokenAddress || "0x0000000000000000000000000000000000000000", signerOrProvider);
36
+ }
37
+ catch (error) {
38
+ console.error("Failed to initialize AintiVirusEVM:", error);
39
+ return null;
40
+ }
41
+ }, [
42
+ config.evm?.factoryAddress,
43
+ config.evm?.tokenAddress,
44
+ walletClient,
45
+ publicClient,
46
+ ]);
47
+ const isEVMReady = !!evmSDK && evmConnected;
48
+ // Solana setup
49
+ const solanaSDK = (0, react_1.useMemo)(() => {
50
+ if (!config.solana?.factoryProgramId ||
51
+ !config.solana?.mixerProgramId ||
52
+ !config.solana?.stakingProgramId) {
53
+ return null;
54
+ }
55
+ if (!config.solanaWallet || !config.solanaConnection) {
56
+ return null;
57
+ }
58
+ try {
59
+ return new solana_1.AintiVirusSolana(config.solana.factoryProgramId, config.solana.mixerProgramId, config.solana.stakingProgramId, config.solanaWallet, config.solanaConnection, config.solana.tokenMint);
60
+ }
61
+ catch (error) {
62
+ console.error("Failed to initialize AintiVirusSolana:", error);
63
+ return null;
64
+ }
65
+ }, [
66
+ config.solana?.factoryProgramId,
67
+ config.solana?.mixerProgramId,
68
+ config.solana?.stakingProgramId,
69
+ config.solana?.tokenMint,
70
+ config.solanaWallet,
71
+ config.solanaConnection,
72
+ ]);
73
+ const isSolanaReady = !!solanaSDK && !!config.solanaWallet?.publicKey;
74
+ // Stake function
75
+ const stake = (0, react_1.useCallback)(async (chainType, amount) => {
76
+ if (chainType === types_1.ChainType.EVM) {
77
+ if (!evmSDK) {
78
+ throw new Error("EVM SDK not initialized");
79
+ }
80
+ return evmSDK.stakeEther(amount);
81
+ }
82
+ else if (chainType === types_1.ChainType.SOLANA) {
83
+ if (!solanaSDK) {
84
+ throw new Error("Solana SDK not initialized");
85
+ }
86
+ return solanaSDK.stakeSol(amount);
87
+ }
88
+ throw new Error(`Unsupported chain type: ${chainType}`);
89
+ }, [evmSDK, solanaSDK]);
90
+ // Unstake function
91
+ const unstake = (0, react_1.useCallback)(async (chainType) => {
92
+ if (chainType === types_1.ChainType.EVM) {
93
+ if (!evmSDK) {
94
+ throw new Error("EVM SDK not initialized");
95
+ }
96
+ return evmSDK.unstakeEth();
97
+ }
98
+ else if (chainType === types_1.ChainType.SOLANA) {
99
+ if (!solanaSDK) {
100
+ throw new Error("Solana SDK not initialized");
101
+ }
102
+ return solanaSDK.unstakeSol();
103
+ }
104
+ throw new Error(`Unsupported chain type: ${chainType}`);
105
+ }, [evmSDK, solanaSDK]);
106
+ return {
107
+ stake,
108
+ unstake,
109
+ isEVMReady,
110
+ isSolanaReady,
111
+ };
112
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Hook for view/read-only functions (EVM or Solana)
3
+ * Use this hook when you only need to read data from contracts
4
+ */
5
+ import { ChainType, EVMHookConfig, SolanaHookConfig, AssetMode, StakeSeason, StakerRecord } from "../types";
6
+ import { Wallet } from "@coral-xyz/anchor";
7
+ import { Connection } from "@solana/web3.js";
8
+ /**
9
+ * Hook configuration for view functions
10
+ */
11
+ export interface ViewHookConfig {
12
+ evm?: EVMHookConfig;
13
+ solana?: SolanaHookConfig;
14
+ solanaWallet?: Wallet;
15
+ solanaConnection?: Connection;
16
+ }
17
+ /**
18
+ * View hook return type
19
+ */
20
+ export interface UseViewReturn {
21
+ getMixer: (chainType: ChainType, mode: AssetMode, amount: bigint) => Promise<string | null>;
22
+ mixerExists: (chainType: ChainType, mode: AssetMode, amount: bigint) => Promise<boolean>;
23
+ calculateDepositAmount: (chainType: ChainType, amount: bigint) => Promise<bigint | null>;
24
+ getFeeRate: (chainType: ChainType) => Promise<bigint | null>;
25
+ getCurrentSeason: (chainType: ChainType) => Promise<bigint | null>;
26
+ getStakeSeason: (chainType: ChainType, seasonId: bigint) => Promise<StakeSeason | null>;
27
+ getStakerRecord: (chainType: ChainType, address: string) => Promise<StakerRecord | null>;
28
+ hasClaimedEth: (chainType: ChainType, address: string, seasonId: bigint) => Promise<boolean | null>;
29
+ hasClaimedToken: (chainType: ChainType, address: string, seasonId: bigint) => Promise<boolean | null>;
30
+ getStakingAddress: (chainType: ChainType) => Promise<string | null>;
31
+ getTokenBalance: (chainType: ChainType, address: string) => Promise<bigint | null>;
32
+ getEthBalance: (chainType: ChainType, address: string) => Promise<bigint | null>;
33
+ isEVMReady: boolean;
34
+ isSolanaReady: boolean;
35
+ }
36
+ /**
37
+ * Hook for view/read-only functions
38
+ * Only initializes what's needed for reading data
39
+ */
40
+ export declare function useView(config: ViewHookConfig): UseViewReturn;
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ /**
3
+ * Hook for view/read-only functions (EVM or Solana)
4
+ * Use this hook when you only need to read data from contracts
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useView = useView;
8
+ const react_1 = require("react");
9
+ const types_1 = require("../types");
10
+ const web3_js_1 = require("@solana/web3.js");
11
+ const evm_1 = require("../evm");
12
+ const solana_1 = require("../solana");
13
+ const wagmi_1 = require("wagmi");
14
+ const utils_1 = require("./utils");
15
+ /**
16
+ * Hook for view/read-only functions
17
+ * Only initializes what's needed for reading data
18
+ */
19
+ function useView(config) {
20
+ // EVM setup
21
+ const { isConnected: evmConnected } = (0, wagmi_1.useAccount)();
22
+ const { data: walletClient } = (0, wagmi_1.useWalletClient)();
23
+ const publicClient = (0, wagmi_1.usePublicClient)();
24
+ const evmSDK = (0, react_1.useMemo)(() => {
25
+ if (!config.evm?.factoryAddress) {
26
+ return null;
27
+ }
28
+ if (!publicClient) {
29
+ return null;
30
+ }
31
+ try {
32
+ const provider = (0, utils_1.createEthersProviderFromViem)(publicClient);
33
+ const signerOrProvider = walletClient
34
+ ? (0, utils_1.createEthersSignerFromViem)(walletClient, publicClient)
35
+ : provider;
36
+ return new evm_1.AintiVirusEVM(config.evm.factoryAddress, config.evm.tokenAddress || "0x0000000000000000000000000000000000000000", signerOrProvider);
37
+ }
38
+ catch (error) {
39
+ console.error("Failed to initialize AintiVirusEVM:", error);
40
+ return null;
41
+ }
42
+ }, [
43
+ config.evm?.factoryAddress,
44
+ config.evm?.tokenAddress,
45
+ walletClient,
46
+ publicClient,
47
+ ]);
48
+ const isEVMReady = !!evmSDK;
49
+ // Solana setup
50
+ const solanaSDK = (0, react_1.useMemo)(() => {
51
+ if (!config.solana?.factoryProgramId ||
52
+ !config.solana?.mixerProgramId ||
53
+ !config.solana?.stakingProgramId) {
54
+ return null;
55
+ }
56
+ if (!config.solanaConnection) {
57
+ return null;
58
+ }
59
+ try {
60
+ // For view functions, we don't need wallet, but SDK requires it
61
+ // We'll create a dummy wallet or handle it gracefully
62
+ if (!config.solanaWallet) {
63
+ return null;
64
+ }
65
+ return new solana_1.AintiVirusSolana(config.solana.factoryProgramId, config.solana.mixerProgramId, config.solana.stakingProgramId, config.solanaWallet, config.solanaConnection, config.solana.tokenMint);
66
+ }
67
+ catch (error) {
68
+ console.error("Failed to initialize AintiVirusSolana:", error);
69
+ return null;
70
+ }
71
+ }, [
72
+ config.solana?.factoryProgramId,
73
+ config.solana?.mixerProgramId,
74
+ config.solana?.stakingProgramId,
75
+ config.solana?.tokenMint,
76
+ config.solanaWallet,
77
+ config.solanaConnection,
78
+ ]);
79
+ const isSolanaReady = !!solanaSDK;
80
+ // View functions
81
+ const getMixer = (0, react_1.useCallback)(async (chainType, mode, amount) => {
82
+ if (chainType === types_1.ChainType.EVM) {
83
+ if (!evmSDK)
84
+ return null;
85
+ return evmSDK.getMixer(mode, amount);
86
+ }
87
+ else if (chainType === types_1.ChainType.SOLANA) {
88
+ if (!solanaSDK)
89
+ return null;
90
+ const mixerPubkey = await solanaSDK.getMixer(mode, amount);
91
+ return mixerPubkey.toString();
92
+ }
93
+ return null;
94
+ }, [evmSDK, solanaSDK]);
95
+ const mixerExists = (0, react_1.useCallback)(async (chainType, mode, amount) => {
96
+ if (chainType === types_1.ChainType.EVM) {
97
+ if (!evmSDK)
98
+ return false;
99
+ return evmSDK.mixerExists(mode, amount);
100
+ }
101
+ else if (chainType === types_1.ChainType.SOLANA) {
102
+ if (!solanaSDK)
103
+ return false;
104
+ return solanaSDK.mixerExists(mode, amount);
105
+ }
106
+ return false;
107
+ }, [evmSDK, solanaSDK]);
108
+ const calculateDepositAmount = (0, react_1.useCallback)(async (chainType, amount) => {
109
+ if (chainType === types_1.ChainType.EVM) {
110
+ if (!evmSDK)
111
+ return null;
112
+ return evmSDK.calculateDepositAmount(amount);
113
+ }
114
+ else if (chainType === types_1.ChainType.SOLANA) {
115
+ if (!solanaSDK)
116
+ return null;
117
+ return solanaSDK.calculateDepositAmount(amount);
118
+ }
119
+ return null;
120
+ }, [evmSDK, solanaSDK]);
121
+ const getFeeRate = (0, react_1.useCallback)(async (chainType) => {
122
+ if (chainType === types_1.ChainType.EVM) {
123
+ if (!evmSDK)
124
+ return null;
125
+ return evmSDK.getFeeRate();
126
+ }
127
+ else if (chainType === types_1.ChainType.SOLANA) {
128
+ if (!solanaSDK)
129
+ return null;
130
+ return solanaSDK.getFeeRate();
131
+ }
132
+ return null;
133
+ }, [evmSDK, solanaSDK]);
134
+ const getCurrentSeason = (0, react_1.useCallback)(async (chainType) => {
135
+ if (chainType === types_1.ChainType.EVM) {
136
+ if (!evmSDK)
137
+ return null;
138
+ return evmSDK.getCurrentStakeSeason();
139
+ }
140
+ else if (chainType === types_1.ChainType.SOLANA) {
141
+ if (!solanaSDK)
142
+ return null;
143
+ return solanaSDK.getCurrentStakeSeason();
144
+ }
145
+ return null;
146
+ }, [evmSDK, solanaSDK]);
147
+ const getStakeSeason = (0, react_1.useCallback)(async (chainType, seasonId) => {
148
+ if (chainType === types_1.ChainType.EVM) {
149
+ if (!evmSDK)
150
+ return null;
151
+ return evmSDK.getStakeSeason(seasonId);
152
+ }
153
+ else if (chainType === types_1.ChainType.SOLANA) {
154
+ if (!solanaSDK)
155
+ return null;
156
+ return solanaSDK.getStakeSeason(seasonId);
157
+ }
158
+ return null;
159
+ }, [evmSDK, solanaSDK]);
160
+ const getStakerRecord = (0, react_1.useCallback)(async (chainType, address) => {
161
+ if (chainType === types_1.ChainType.EVM) {
162
+ if (!evmSDK)
163
+ return null;
164
+ return evmSDK.getStakerRecord(address);
165
+ }
166
+ else if (chainType === types_1.ChainType.SOLANA) {
167
+ if (!solanaSDK)
168
+ return null;
169
+ return solanaSDK.getStakerRecord(address);
170
+ }
171
+ return null;
172
+ }, [evmSDK, solanaSDK]);
173
+ const hasClaimedEth = (0, react_1.useCallback)(async (chainType, address, seasonId) => {
174
+ if (chainType === types_1.ChainType.EVM) {
175
+ if (!evmSDK)
176
+ return null;
177
+ return evmSDK.hasClaimedEth(address, seasonId);
178
+ }
179
+ else if (chainType === types_1.ChainType.SOLANA) {
180
+ if (!solanaSDK)
181
+ return null;
182
+ return solanaSDK.hasClaimedSol(address, seasonId);
183
+ }
184
+ return null;
185
+ }, [evmSDK, solanaSDK]);
186
+ const hasClaimedToken = (0, react_1.useCallback)(async (chainType, address, seasonId) => {
187
+ if (chainType === types_1.ChainType.EVM) {
188
+ if (!evmSDK)
189
+ return null;
190
+ return evmSDK.hasClaimedToken(address, seasonId);
191
+ }
192
+ else if (chainType === types_1.ChainType.SOLANA) {
193
+ if (!solanaSDK)
194
+ return null;
195
+ return solanaSDK.hasClaimedToken(address, seasonId);
196
+ }
197
+ return null;
198
+ }, [evmSDK, solanaSDK]);
199
+ const getStakingAddress = (0, react_1.useCallback)(async (chainType) => {
200
+ if (chainType === types_1.ChainType.EVM) {
201
+ if (!evmSDK)
202
+ return null;
203
+ return evmSDK.getStakingAddress();
204
+ }
205
+ else if (chainType === types_1.ChainType.SOLANA) {
206
+ if (!solanaSDK)
207
+ return null;
208
+ const stakingAddress = await solanaSDK.getStakingAddress();
209
+ return stakingAddress.toString();
210
+ }
211
+ return null;
212
+ }, [evmSDK, solanaSDK]);
213
+ const getTokenBalance = (0, react_1.useCallback)(async (chainType, address) => {
214
+ if (chainType === types_1.ChainType.EVM) {
215
+ if (!evmSDK)
216
+ return null;
217
+ return evmSDK.getTokenBalance(address);
218
+ }
219
+ else if (chainType === types_1.ChainType.SOLANA) {
220
+ if (!solanaSDK)
221
+ return null;
222
+ return solanaSDK.getTokenBalance(new web3_js_1.PublicKey(address));
223
+ }
224
+ return null;
225
+ }, [evmSDK, solanaSDK]);
226
+ const getEthBalance = (0, react_1.useCallback)(async (chainType, address) => {
227
+ if (chainType === types_1.ChainType.EVM) {
228
+ if (!evmSDK)
229
+ return null;
230
+ return evmSDK.getEthBalance(address);
231
+ }
232
+ else if (chainType === types_1.ChainType.SOLANA) {
233
+ if (!solanaSDK)
234
+ return null;
235
+ return solanaSDK.getSolBalance(new web3_js_1.PublicKey(address));
236
+ }
237
+ return null;
238
+ }, [evmSDK, solanaSDK]);
239
+ return {
240
+ getMixer,
241
+ mixerExists,
242
+ calculateDepositAmount,
243
+ getFeeRate,
244
+ getCurrentSeason,
245
+ getStakeSeason,
246
+ getStakerRecord,
247
+ hasClaimedEth,
248
+ hasClaimedToken,
249
+ getStakingAddress,
250
+ getTokenBalance,
251
+ getEthBalance,
252
+ isEVMReady,
253
+ isSolanaReady,
254
+ };
255
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Hook for withdrawing (EVM or Solana)
3
+ * Use this hook when you only need withdraw functionality
4
+ */
5
+ import { ChainType, EVMHookConfig, SolanaHookConfig, AssetMode, WithdrawalProof } from "../types";
6
+ import { Wallet } from "@coral-xyz/anchor";
7
+ import { Connection } from "@solana/web3.js";
8
+ import { TransactionResult } from "../types";
9
+ /**
10
+ * Hook configuration for withdraw
11
+ */
12
+ export interface WithdrawHookConfig {
13
+ evm?: EVMHookConfig;
14
+ solana?: SolanaHookConfig;
15
+ solanaWallet?: Wallet;
16
+ solanaConnection?: Connection;
17
+ }
18
+ /**
19
+ * Withdraw hook return type
20
+ */
21
+ export interface UseWithdrawReturn {
22
+ withdraw: (chainType: ChainType, proof: WithdrawalProof, amount: bigint, mode: AssetMode) => Promise<TransactionResult>;
23
+ isEVMReady: boolean;
24
+ isSolanaReady: boolean;
25
+ }
26
+ /**
27
+ * Hook for withdrawing funds
28
+ * Only initializes what's needed for withdrawals
29
+ */
30
+ export declare function useWithdraw(config: WithdrawHookConfig): UseWithdrawReturn;