@@ -28,7 +28,7 @@ interface UserLoginResponse {
28
28
29
29
interface GetSmartWalletRootSignerParams {
30
30
chain_type : "Evm" | "Solana" | "Tron" ;
31
- index : number ;
31
+ wallet_index : number ;
32
32
}
33
33
34
34
// JSON-RPC request helper
@@ -49,7 +49,7 @@ async function makeRpcRequest<T>(
49
49
// If params is already an array (for methods like omni_getWeb3SignInMessage), it's the actual params
50
50
// If params is an object or null/undefined, use it directly
51
51
const rpcParams = params ?? null ;
52
-
52
+
53
53
const requestBody = {
54
54
jsonrpc : "2.0" ,
55
55
method,
@@ -82,8 +82,8 @@ async function makeRpcRequest<T>(
82
82
if ( data . error ) {
83
83
console . error ( `[TEE Worker RPC] Error from ${ method } :` , data . error ) ;
84
84
// Include error code in the error message for better debugging
85
- const errorMessage = data . error . data
86
- ? `${ data . error . message } (${ data . error . data } )`
85
+ const errorMessage = data . error . data
86
+ ? `${ data . error . message } (${ data . error . data } )`
87
87
: data . error . message || "RPC error" ;
88
88
throw new Error ( errorMessage ) ;
89
89
}
@@ -99,10 +99,10 @@ export async function getWeb3SignInMessage(
99
99
// The omniAccount should already be a properly formatted 32-byte hex string (64 chars) with 0x prefix
100
100
// from calculateOmniAccount function
101
101
console . log ( '[TEE Worker] Using omni account:' , omniAccount ) ;
102
-
102
+
103
103
// Pass parameters as an array for positional arguments
104
104
return makeRpcRequest < Web3SignInMessageResponse > (
105
- "omni_getWeb3SignInMessage" ,
105
+ "omni_getWeb3SignInMessage" ,
106
106
[ clientId , omniAccount ]
107
107
) ;
108
108
}
@@ -118,7 +118,7 @@ export async function loginWithEvm(
118
118
// The server expects the message to be a JSON string of the payload
119
119
const message = JSON . stringify ( messagePayload ) ;
120
120
console . log ( "[TEE Worker] Message to sign:" , message ) ;
121
-
121
+
122
122
const signature = await walletClient . signMessage ( {
123
123
account : evmAddress as `0x${string } `,
124
124
message,
@@ -140,7 +140,7 @@ export async function loginWithEvm(
140
140
} ;
141
141
142
142
console . log ( "[TEE Worker] UserLogin params:" , JSON . stringify ( params , null , 2 ) ) ;
143
-
143
+
144
144
// Pass the params object directly
145
145
return makeRpcRequest < UserLoginResponse > ( "omni_userLogin" , params ) ;
146
146
}
@@ -153,7 +153,7 @@ export async function getSmartWalletRootSigner(
153
153
) : Promise < string > {
154
154
const params : GetSmartWalletRootSignerParams = {
155
155
chain_type : chainType ,
156
- index,
156
+ wallet_index : index ,
157
157
} ;
158
158
159
159
return makeRpcRequest < string > ( "omni_getSmartWalletRootSigner" , params , idToken ) ;
@@ -205,16 +205,16 @@ export async function authorizeTEEWorker(
205
205
} ;
206
206
} catch ( error ) {
207
207
console . error ( `[TEE Worker] Authorization attempt ${ retryCount + 1 } failed:` , error ) ;
208
-
208
+
209
209
// If this was our last retry, throw the error
210
210
if ( retryCount >= maxRetries ) {
211
211
throw error ;
212
212
}
213
-
213
+
214
214
// Wait a bit before retrying to ensure any server-side state is cleared
215
215
console . log ( "[TEE Worker] Waiting 1 second before retry..." ) ;
216
216
await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
217
-
217
+
218
218
retryCount ++ ;
219
219
}
220
220
}
0 commit comments