|
8 | 8 | elizaLogger, |
9 | 9 | TEEMode, |
10 | 10 | ServiceType, |
11 | | - getTypedService, |
12 | 11 | } from '@elizaos/core'; |
13 | 12 | import type { |
14 | 13 | Account, |
@@ -268,22 +267,27 @@ export const initWalletProvider = async (runtime: IAgentRuntime) => { |
268 | 267 | throw new Error("WALLET_SECRET_SALT required when TEE_MODE is enabled"); |
269 | 268 | } |
270 | 269 |
|
271 | | - // Get the TEE service as a TypedService |
272 | | - const teeService = getTypedService(runtime, ServiceType.TEE); |
| 270 | + // Get the TEE service |
| 271 | + const teeService = runtime.getService(ServiceType.TEE); |
273 | 272 |
|
| 273 | + // Type guard to check if the service exists and has the required method |
274 | 274 | if (!teeService) { |
275 | 275 | throw new Error('TEE service not found'); |
276 | 276 | } |
277 | 277 |
|
278 | | - // Use the generic process method |
279 | | - const deriveKeyResult = await teeService.process({ |
280 | | - action: 'deriveEcdsaKeypair', |
281 | | - salt: walletSecretSalt, |
282 | | - subject: 'evm', |
283 | | - agentId: runtime.agentId, |
284 | | - }); |
| 278 | + // Check if the service has the deriveEcdsaKeypair method and it's a function |
| 279 | + if (typeof (teeService as any).deriveEcdsaKeypair !== 'function') { |
| 280 | + throw new Error('TEE service does not implement deriveEcdsaKeypair method'); |
| 281 | + } |
| 282 | + |
| 283 | + // Directly call the deriveEcdsaKeypair method |
| 284 | + const { keypair, attestation } = await (teeService as any).deriveEcdsaKeypair( |
| 285 | + walletSecretSalt, |
| 286 | + 'evm', |
| 287 | + runtime.agentId |
| 288 | + ); |
285 | 289 |
|
286 | | - return new WalletProvider(deriveKeyResult.keypair, runtime, chains); |
| 290 | + return new WalletProvider(keypair, runtime, chains); |
287 | 291 | } |
288 | 292 | const privateKey = runtime.getSetting("EVM_PRIVATE_KEY") as `0x${string}`; |
289 | 293 | if (!privateKey) { |
|
0 commit comments