-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
228 lines (200 loc) · 5.09 KB
/
app.ts
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
export enum HapticFeedbackMethod {
selection = "selection",
impactLight = "impactLight",
notificationSuccess = "notificationSuccess",
notificationError = "notificationError",
}
export enum LetoAppPlatform {
ios = "ios",
android = "android",
macos = "macos",
}
export interface LetoAppSystemVersion {
version: string;
major: number;
minor: number;
patch: number;
}
export enum LetoAppTheme {
dark = "dark",
light = "light",
}
export enum LetoAppWalletSource {
Import = "import",
Connect = "connect",
}
export interface ISafeAreaInsets {
top: number;
right: number;
bottom: number;
left: number;
}
export type LetoAppStateStatus =
| "active"
| "background"
| "inactive"
| "unknown"
| "extension";
export interface ILetoKeyboardAnimationData {
duration: number;
easing: string;
}
export interface ILetoAppChangeThemeEvent {
type: "change_theme";
payload: {
theme: LetoAppTheme;
};
}
export interface ILetoAppStateEvent {
type: "app_state";
payload: {
appState: LetoAppStateStatus;
};
}
export interface ILetoKeyboardDidShowEvent {
type: "keyboard_did_show";
payload: ILetoKeyboardAnimationData & {
height: number;
};
}
export interface ILetoKeyboardDidHideEvent {
type: "keyboard_did_hide";
payload: ILetoKeyboardAnimationData;
}
export interface ILetoAccessTokenUpdatedEvent {
type: "access_token_updated";
payload: {
accessToken: string;
};
}
export interface ILetoContactsUpdatedEvent {
type: "contacts_updated";
}
export type ILetoAppEvent =
| ILetoAppChangeThemeEvent
| ILetoAppStateEvent
| ILetoKeyboardDidShowEvent
| ILetoKeyboardDidHideEvent
| ILetoAccessTokenUpdatedEvent
| ILetoContactsUpdatedEvent;
export interface ILetoShareTextOptions {
type: "text";
message: string;
title?: string;
}
export interface ILetoShareImageOptions {
type: "image";
/** base64 image */
image: string;
title?: string;
}
export interface ILetoShareUrlOptions {
type: "url";
url: string;
title?: string;
}
export type ILetoShareOptions =
| ILetoShareTextOptions
| ILetoShareImageOptions
| ILetoShareUrlOptions;
export type CodeScannerResponse =
| {
network: "ethereum";
target_address: string;
chain_id?: `${number}`;
function_name?: string;
prefix?: string;
parameters?: Record<string, string>;
}
| { network: "tron"; address: string };
export interface ILetoAppPhoneContact {
recordID: string;
firstName: string;
lastName: string;
phone: string;
thumbnail: string | null;
}
export interface ILetoWalletListItem {
identifier: string;
name: string;
isMnemonic: boolean;
accounts: {
ethereum: string;
};
isActive: boolean;
}
export type PhoneContactsResponse = ILetoAppPhoneContact[];
export enum ILetoInstalledAppId {
Trust = "trust",
MetaMask = "metamask",
Rainbow = "rainbow",
Zerion = "zerion",
CoinbaseWallet = "coinbase_wallet",
Binance = "binance",
Coinbase = "coinbase",
}
export enum ILetoInstalledAppType {
Exchange = "exchange",
Wallet = "wallet",
}
export interface ILetoInstalledApp {
id: ILetoInstalledAppId;
type: ILetoInstalledAppType;
name: string;
}
export type InstalledAppsResponse = ILetoInstalledApp[];
/** window.letoApp */
export interface ILetoAppInjected {
version: string;
initialTheme: LetoAppTheme;
platform: LetoAppPlatform;
systemVersion: LetoAppSystemVersion;
safeAreaInsets: ISafeAreaInsets;
initialKeyboardAnimationData: ILetoKeyboardAnimationData;
accessToken: string;
walletSource: LetoAppWalletSource;
preferredCurrency: string;
refreshAccessToken: () => Promise<string>;
getClipboard: () => Promise<string>;
hapticFeedback: (method: HapticFeedbackMethod) => Promise<void>;
disconnect: () => Promise<void>;
openDevMenu: () => Promise<void>;
openSupport: () => Promise<void>;
openPrivacySettings: () => Promise<void>;
openCodeScanner: () => Promise<CodeScannerResponse>;
/**
* Note: if app does not have access to contacts promise will be rejected
*/
getPhoneContacts: () => Promise<PhoneContactsResponse>;
/**
* if user sync contacts promise will be resolved, otherwise rejected
*/
requestContactsPermission: () => Promise<void>;
/**
* returns true if contacts pemission is authorized, otherwise returns false
*/
checkContactsPermission: () => Promise<boolean>;
openMnemonicBackup: (address: string) => Promise<void>;
openPrivateKeyBackup: (address: string) => Promise<void>;
changeActiveAddress: (address: string) => Promise<void>;
forgetWallet: (address: string) => Promise<void>;
addWallet: () => Promise<ILetoWalletListItem[]>;
getWalletList: () => Promise<ILetoWalletListItem[]>;
getInstalledApps: () => Promise<InstalledAppsResponse>;
openAppTransferUrl: (
id: ILetoInstalledAppId,
address: string
) => Promise<void>;
/**
* returns true if phone was successfuly added
*
* returns false if user went back
*/
openAddPhone: () => Promise<boolean>;
/**
* reload WebView
*/
reload: () => void;
share: (options: ILetoShareOptions) => Promise<void>;
listen: (callback: (event: ILetoAppEvent) => void) => () => void;
}