add smart wallet balances rpc method
Browse files
src/tools/crypto_evm_wallet_toolkit.py
CHANGED
|
@@ -9,9 +9,12 @@ class CryptoEVMWalletTools(Toolkit):
|
|
| 9 |
super().__init__(name="crypto_evm_wallet_tools")
|
| 10 |
|
| 11 |
# Registering methods to make them accessible via the toolkit
|
| 12 |
-
self.register(self.get_evm_wallet_address)
|
| 13 |
self.register(self.get_supported_evm_chains)
|
| 14 |
self.register(self.get_evm_smart_wallet_address)
|
|
|
|
|
|
|
|
|
|
| 15 |
self.chains = self.get_supported_evm_chains()
|
| 16 |
|
| 17 |
def get_supported_evm_chains(self) -> list[str]:
|
|
@@ -30,14 +33,50 @@ class CryptoEVMWalletTools(Toolkit):
|
|
| 30 |
response = asyncio.run(rpc_call(method_name="getEVMSupportedChains", params=params))
|
| 31 |
return f"{response}"
|
| 32 |
|
| 33 |
-
def get_evm_wallet_address(self, user_email: str, chain: str, testnet: bool = True) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
"""
|
| 35 |
-
Fetches
|
| 36 |
-
Creates and returns
|
| 37 |
|
| 38 |
Parameters:
|
| 39 |
-
- user_email (str): The email of the user for whom the wallet is being
|
| 40 |
- chain (ethereum | binance | base | polygon): The EVM chain for which the wallet is being fetched.
|
|
|
|
| 41 |
- testnet (bool, optional): A flag indicating whether the wallet should be on the testnet. Defaults to `True`.
|
| 42 |
|
| 43 |
Returns:
|
|
@@ -47,37 +86,37 @@ class CryptoEVMWalletTools(Toolkit):
|
|
| 47 |
None
|
| 48 |
|
| 49 |
Note:
|
| 50 |
-
This method uses asyncio.run() to run the asynchronous RPC call.
|
| 51 |
"""
|
| 52 |
-
logger.info(f"
|
| 53 |
|
| 54 |
params = {
|
| 55 |
'chain': chain,
|
|
|
|
| 56 |
'testnet': testnet,
|
| 57 |
'userEmail': user_email,
|
| 58 |
}
|
| 59 |
-
response = asyncio.run(rpc_call(method_name="
|
| 60 |
return f"{response}"
|
| 61 |
|
| 62 |
-
def
|
| 63 |
self,
|
|
|
|
| 64 |
user_email: str,
|
| 65 |
chain: str,
|
| 66 |
-
gasless: bool = True,
|
| 67 |
testnet: bool = True
|
| 68 |
) -> str:
|
| 69 |
"""
|
| 70 |
-
Fetches a smart EVM wallet address for the given user email and supported chain.
|
| 71 |
-
Creates and returns a smart EVM wallet address for the given user email and supported chain.
|
| 72 |
|
| 73 |
Parameters:
|
|
|
|
| 74 |
- user_email (str): The email of the user for whom the wallet is being fetched.
|
| 75 |
-
- chain (
|
| 76 |
-
- gasless (bool, optional): A flag indicating whether the wallet should be gasless. Defaults to `True`.
|
| 77 |
- testnet (bool, optional): A flag indicating whether the wallet should be on the testnet. Defaults to `True`.
|
| 78 |
|
| 79 |
Returns:
|
| 80 |
-
- str: A string representation of the response from the RPC call.
|
| 81 |
|
| 82 |
Raises:
|
| 83 |
None
|
|
@@ -89,9 +128,9 @@ class CryptoEVMWalletTools(Toolkit):
|
|
| 89 |
|
| 90 |
params = {
|
| 91 |
'chain': chain,
|
| 92 |
-
'
|
| 93 |
'testnet': testnet,
|
| 94 |
'userEmail': user_email,
|
| 95 |
}
|
| 96 |
-
response = asyncio.run(rpc_call(method_name="
|
| 97 |
return f"{response}"
|
|
|
|
| 9 |
super().__init__(name="crypto_evm_wallet_tools")
|
| 10 |
|
| 11 |
# Registering methods to make them accessible via the toolkit
|
| 12 |
+
# self.register(self.get_evm_wallet_address)
|
| 13 |
self.register(self.get_supported_evm_chains)
|
| 14 |
self.register(self.get_evm_smart_wallet_address)
|
| 15 |
+
self.register(self.get_evm_smart_wallet_balances)
|
| 16 |
+
|
| 17 |
+
# Fetching the list of supported EVM chains
|
| 18 |
self.chains = self.get_supported_evm_chains()
|
| 19 |
|
| 20 |
def get_supported_evm_chains(self) -> list[str]:
|
|
|
|
| 33 |
response = asyncio.run(rpc_call(method_name="getEVMSupportedChains", params=params))
|
| 34 |
return f"{response}"
|
| 35 |
|
| 36 |
+
# def get_evm_wallet_address(self, user_email: str, chain: str, testnet: bool = True) -> str:
|
| 37 |
+
# """
|
| 38 |
+
# Fetches an EVM wallet address for the given user email and supported chain.
|
| 39 |
+
# Creates and returns an EVM wallet address for the given user email and supported chain.
|
| 40 |
+
|
| 41 |
+
# Parameters:
|
| 42 |
+
# - user_email (str): The email of the user for whom the wallet is being created.
|
| 43 |
+
# - chain (ethereum | binance | base | polygon): The EVM chain for which the wallet is being fetched.
|
| 44 |
+
# - testnet (bool, optional): A flag indicating whether the wallet should be on the testnet. Defaults to `True`.
|
| 45 |
+
|
| 46 |
+
# Returns:
|
| 47 |
+
# - str: A string representation of the response from the RPC call.
|
| 48 |
+
|
| 49 |
+
# Raises:
|
| 50 |
+
# None
|
| 51 |
+
|
| 52 |
+
# Note:
|
| 53 |
+
# This method uses asyncio.run() to run the asynchronous RPC call.
|
| 54 |
+
# """
|
| 55 |
+
# logger.info(f"Creating crypto wallet account for {user_email}")
|
| 56 |
+
|
| 57 |
+
# params = {
|
| 58 |
+
# 'chain': chain,
|
| 59 |
+
# 'testnet': testnet,
|
| 60 |
+
# 'userEmail': user_email,
|
| 61 |
+
# }
|
| 62 |
+
# response = asyncio.run(rpc_call(method_name="getEVMWallet", params=params))
|
| 63 |
+
# return f"{response}"
|
| 64 |
+
|
| 65 |
+
def get_evm_smart_wallet_address(
|
| 66 |
+
self,
|
| 67 |
+
user_email: str,
|
| 68 |
+
chain: str,
|
| 69 |
+
gasless: bool = True,
|
| 70 |
+
testnet: bool = True
|
| 71 |
+
) -> str:
|
| 72 |
"""
|
| 73 |
+
Fetches a smart EVM wallet address for the given user email and supported chain.
|
| 74 |
+
Creates and returns a smart EVM wallet address for the given user email and supported chain.
|
| 75 |
|
| 76 |
Parameters:
|
| 77 |
+
- user_email (str): The email of the user for whom the wallet is being fetched.
|
| 78 |
- chain (ethereum | binance | base | polygon): The EVM chain for which the wallet is being fetched.
|
| 79 |
+
- gasless (bool, optional): A flag indicating whether the wallet should be gasless. Defaults to `True`.
|
| 80 |
- testnet (bool, optional): A flag indicating whether the wallet should be on the testnet. Defaults to `True`.
|
| 81 |
|
| 82 |
Returns:
|
|
|
|
| 86 |
None
|
| 87 |
|
| 88 |
Note:
|
| 89 |
+
This method uses `asyncio.run()` to run the asynchronous RPC call.
|
| 90 |
"""
|
| 91 |
+
logger.info(f"Fetching crypto wallet account for {user_email}")
|
| 92 |
|
| 93 |
params = {
|
| 94 |
'chain': chain,
|
| 95 |
+
'gasless': gasless,
|
| 96 |
'testnet': testnet,
|
| 97 |
'userEmail': user_email,
|
| 98 |
}
|
| 99 |
+
response = asyncio.run(rpc_call(method_name="getEVMSmartWallet", params=params))
|
| 100 |
return f"{response}"
|
| 101 |
|
| 102 |
+
def get_evm_smart_wallet_balances(
|
| 103 |
self,
|
| 104 |
+
address: str,
|
| 105 |
user_email: str,
|
| 106 |
chain: str,
|
|
|
|
| 107 |
testnet: bool = True
|
| 108 |
) -> str:
|
| 109 |
"""
|
| 110 |
+
Fetches the balances of a smart EVM wallet address for the given user email and supported chain.
|
|
|
|
| 111 |
|
| 112 |
Parameters:
|
| 113 |
+
- address (str): The address of the smart EVM wallet for which the balances are being fetched.
|
| 114 |
- user_email (str): The email of the user for whom the wallet is being fetched.
|
| 115 |
+
- chain (str): The EVM chain for which the wallet is being fetched.
|
|
|
|
| 116 |
- testnet (bool, optional): A flag indicating whether the wallet should be on the testnet. Defaults to `True`.
|
| 117 |
|
| 118 |
Returns:
|
| 119 |
+
- str: A string representation of the response from the RPC call containing the balances of the smart EVM wallet address.
|
| 120 |
|
| 121 |
Raises:
|
| 122 |
None
|
|
|
|
| 128 |
|
| 129 |
params = {
|
| 130 |
'chain': chain,
|
| 131 |
+
'address': address,
|
| 132 |
'testnet': testnet,
|
| 133 |
'userEmail': user_email,
|
| 134 |
}
|
| 135 |
+
response = asyncio.run(rpc_call(method_name="getEVMSmartWalletAddressBalances", params=params))
|
| 136 |
return f"{response}"
|