(keyResponse: GetKeyResponse | GetTlsKeyResponse)
| 11 | * Current implementation uses raw key material without proper hashing. |
| 12 | */ |
| 13 | export function toViemAccount(keyResponse: GetKeyResponse | GetTlsKeyResponse) { |
| 14 | // Keep legacy behavior for GetTlsKeyResponse, but with warning. |
| 15 | if (keyResponse.__name__ === 'GetTlsKeyResponse') { |
| 16 | console.warn('toViemAccount: Please don\'t use `deriveKey` method to get key, use `getKey` instead.') |
| 17 | const hex = Array.from(keyResponse.asUint8Array(32)).map(b => b.toString(16).padStart(2, '0')).join('') |
| 18 | return privateKeyToAccount(`0x${hex}`) |
| 19 | } |
| 20 | const hex = Array.from(keyResponse.key).map(b => b.toString(16).padStart(2, '0')).join('') |
| 21 | return privateKeyToAccount(`0x${hex}`) |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Creates a Viem account from DeriveKeyResponse using secure key derivation. |
no test coverage detected