Skip to content

Commit 3d2aafd

Browse files
committed
fix: tee service
1 parent 5834f3d commit 3d2aafd

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

src/providers/wallet.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
elizaLogger,
99
TEEMode,
1010
ServiceType,
11-
getTypedService,
1211
} from '@elizaos/core';
1312
import type {
1413
Account,
@@ -268,22 +267,27 @@ export const initWalletProvider = async (runtime: IAgentRuntime) => {
268267
throw new Error("WALLET_SECRET_SALT required when TEE_MODE is enabled");
269268
}
270269

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);
273272

273+
// Type guard to check if the service exists and has the required method
274274
if (!teeService) {
275275
throw new Error('TEE service not found');
276276
}
277277

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+
);
285289

286-
return new WalletProvider(deriveKeyResult.keypair, runtime, chains);
290+
return new WalletProvider(keypair, runtime, chains);
287291
}
288292
const privateKey = runtime.getSetting("EVM_PRIVATE_KEY") as `0x${string}`;
289293
if (!privateKey) {

0 commit comments

Comments
 (0)