-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTurnkeyModule.ts
More file actions
48 lines (36 loc) · 1.26 KB
/
TurnkeyModule.ts
File metadata and controls
48 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { NativeModules } from 'react-native';
// Define type for native module
interface TurnkeyNativeModuleType {
onJsResponse: (callbackId: string, result: string) => void;
onAuthRouteToWallet: () => void;
onAuthRouteToDesktopQR: () => void;
onAuthCompleted: (onboardingSignature: string, evmAddress: string, svmAddress: string,
mnemonics: string, loginMethod: string, userEmail: string | undefined, dydxAddress: string | undefined) => void;
onAppleAuthRequest: (nonce: string) => void;
onUploadDydxAddressUploadResponse: (dydxAddress: string, result: string) => void;
onTrackingEvent: (eventName: string, eventParams: Record<string, string>) => void;
}
// Safely cast NativeModules
export const { TurnkeyNativeModule } = NativeModules as {
TurnkeyNativeModule: TurnkeyNativeModuleType;
};
// Define type for event payload
export interface NativeToJsRequestEvent {
callbackId: string;
}
export interface AppleSignInCompletedEvent {
identityToken: string | null;
error: string | null;
}
export interface EmailTokenReceivedEvent {
token: string;
}
export interface DydxAddressReceivedEvent {
callbackId: string;
dydxAddress: string;
}
export interface FetchDepositAddressesEvent {
callbackId: string;
dydxAddress: string;
indexerUrl: string;
}