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

Function toViemAccount

sdk/js/src/viem.ts:13–22  ·  view source on GitHub ↗
(keyResponse: GetKeyResponse | GetTlsKeyResponse)

Source from the content-addressed store, hash-verified

11 * Current implementation uses raw key material without proper hashing.
12 */
13export 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.

Callers 2

viem.test.tsFile · 0.90
mainFunction · 0.85

Calls 2

fromMethod · 0.45
asUint8ArrayMethod · 0.45

Tested by

no test coverage detected