File size: 1,823 Bytes
1574c80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import asyncio
from phi.tools import Toolkit
from phi.utils.log import logger
from src.libs.rpc_client import rpc_call

class CryptoWalletTools(Toolkit):
    def __init__(self):
        super().__init__(name="crypto_wallet_tools")

        # Registering methods to make them accessible via the toolkit
        self.register(self.create_crypto_wallet)

    def create_crypto_wallet(self, user_email: str) -> str:
        """
        Creates a crypto wallet account for the given user email.

        Parameters:
        user_email (str): The email of the user for whom the wallet is being created.

        Returns:
        str: A string representation of the response from the RPC call.

        Raises:
        None

        Note:
        This method uses asyncio.run() to run the asynchronous RPC call.
        """
        logger.info(f"Creating crypto wallet account for {user_email}")
        
        params = {
            'userEmail': user_email,
        }
        response = asyncio.run(rpc_call(method_name="createLocalWallet", params=params))
        return f"{response}"
    
    def get_crypto_wallet(self, user_email: str) -> str:
        """
        Fetches the crypto wallet account for the given user email.

        Parameters:
        user_email (str): The email of the user for whom the wallet is being fetched.

        Returns:
        str: A string representation of the response from the RPC call.

        Raises:
        None

        Note:
        This method uses asyncio.run() to run the asynchronous RPC call.
        """
        logger.info(f"Fetching crypto wallet account for {user_email}")
        
        params = {
            'userEmail': user_email,
        }
        response = asyncio.run(rpc_call(method_name="getLocalWallet", params=params))
        return f"{response}"