MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / to_account

Function to_account

sdk/python/src/dstack_sdk/ethereum.py:21–43  ·  view source on GitHub ↗

Create an Ethereum account from DstackClient key response. DEPRECATED: Use to_account_secure instead. This method has security concerns. Current implementation uses raw key material without proper hashing. Args: get_key_response: Response from get_key() or get_tls_key() Re

(get_key_response: GetKeyResponse | GetTlsKeyResponse)

Source from the content-addressed store, hash-verified

19
20
21def to_account(get_key_response: GetKeyResponse | GetTlsKeyResponse) -> LocalAccount:
22 """Create an Ethereum account from DstackClient key response.
23
24 DEPRECATED: Use to_account_secure instead. This method has security concerns.
25 Current implementation uses raw key material without proper hashing.
26
27 Args:
28 get_key_response: Response from get_key() or get_tls_key()
29
30 Returns:
31 Account: Ethereum account object
32
33 """
34 if isinstance(get_key_response, GetTlsKeyResponse):
35 warnings.warn(
36 "to_account: Please don't use getTlsKey method to get key, use getKey instead.",
37 DeprecationWarning,
38 stacklevel=2,
39 )
40 key_bytes = get_key_response.as_uint8array(32)
41 return Account.from_key(key_bytes) # type: ignore[no-any-return]
42 else: # GetKeyResponse
43 return Account.from_key(get_key_response.decode_key()) # type: ignore[no-any-return]
44
45
46def to_account_secure(

Callers 4

mainFunction · 0.90
test_async_to_accountFunction · 0.90
test_sync_to_accountFunction · 0.90

Calls 2

as_uint8arrayMethod · 0.80
decode_keyMethod · 0.45

Tested by 4

mainFunction · 0.72
test_async_to_accountFunction · 0.72
test_sync_to_accountFunction · 0.72