-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
471 lines (412 loc) · 8.94 KB
/
types.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
import { BottomTabScreenProps } from '@react-navigation/bottom-tabs'
import {
CompositeScreenProps,
NavigatorScreenParams,
} from '@react-navigation/native'
import { NativeStackScreenProps } from '@react-navigation/native-stack'
import { ImageSourcePropType } from 'react-native'
import { Notification } from 'expo-notifications'
import type { Transaction } from '@near-wallet-selector/core'
declare global {
namespace ReactNavigation {
interface RootParamList extends RootStackParamList {}
}
}
export type RootStackParamList = {
Root: NavigatorScreenParams<RootTabParamList> | undefined
TokenDetail: { token: Token }
DAppView: { project?: Project; url?: string }
Transfer: { receiver?: string; token?: Token }
NotFound: undefined
Notification: { noti?: iNotification }
SearchDAppResult: { keyword: string }
SearchDApp: undefined
Scanner: { fromPage: string }
WalletsManage: undefined
WalletDetail: { wallet: Wallet }
About: undefined
Security: undefined
NewContact: { contact?: Contact }
PINCode: { onConfirmed: () => void }
ContactsManage: undefined
Start: { new?: boolean; chain?: Chain }
Create: { new?: boolean; chain?: Chain }
Restore: { new?: boolean; chain?: Chain }
WalletExport: { wallet: Wallet }
ChangePINCode: undefined
Finance: undefined
ConnectLedger: { chain: Chain }
LedgerDevice: undefined
Networks: undefined
ChainNetworks: { chain?: Chain }
NewNetwork: { network?: CustomNetwork; chain: Chain }
NFTDetail: { nft: NFTItem; metadata: NFTContractMetadata }
AuthorizedApps: undefined
SetupPINCode: undefined
}
export type RootStackScreenProps<Screen extends keyof RootStackParamList> =
NativeStackScreenProps<RootStackParamList, Screen>
export type RootTabParamList = {
Home: undefined
Finance: undefined
Explore: undefined
Settings: undefined
}
export type RootTabScreenProps<Screen extends keyof RootTabParamList> =
CompositeScreenProps<
BottomTabScreenProps<RootTabParamList, Screen>,
NativeStackScreenProps<RootStackParamList>
>
export type NearPrice = {
cny: number
eur: number
last_updated_at: number
usd: number
}
export enum AppChainType {
ATOCHA = 'atocha',
DEBIO = 'debionetwork',
FUSOTAO = 'fusotao',
MYRIAD = 'myriad',
DISCOVOL = 'discovol',
}
export type Token = {
name: string
symbol: string
price: number
balance: string
icon: ImageSourcePropType | string
decimals: number
isNative?: boolean
contractId?: string
address?: string
chain: Chain
networkType: CombineNetworkType
}
export type NFT = {
base_uri: string
icon: string
name: string
reference: string
reference_hash: string
symbol: string
items: any[]
id: string
}
type URL = string
export type AccountId = string
export type Project = {
dapp: URL
logo: URL
title: string
oneliner?: string
website: URL
query?: {
address: string
refer: string
}
}
export interface DApp {
authorId: string
dapp: URL
logo: URL
title: string
oneliner: string
website: URL
}
export type TxPreview = {
from: Wallet
to: string
amount: string
token: Token
}
export type ToastType = 'success' | 'error' | 'info' | 'warning'
export enum LOGIN_ACCESS_TYPES {
FULL_ACCESS = 'fullAccess',
LIMITED_ACCESS = 'limitedAccess',
}
export type NearLogin = {
loginAccessType: LOGIN_ACCESS_TYPES
failureUrl?: string
successUrl?: string
contractId?: string
invalidContractId?: string
publicKey?: string
}
export type NearSign = {
transactions?: string
meta?: string
callbackUrl?: string
}
export type NearLinkDrop = {
fundingContract: string
fundingKey: string
}
export enum PUB {
REFRESH_TOKENLIST = 'REFRESH_TOKENLIST',
TOAST_MESSAGE = 'TOAST_MESSAGE',
TOAST_HIDE = 'TOAST_HIDE',
ON_DAPP_CONNECT = 'ON_DAPP_CONNECT',
ON_DAPP_DISCONNECT = 'ON_DAPP_DISCONNECT',
ON_DAPP_SIGN = 'ON_DAPP_SIGN',
}
export enum WC_STATUS {
UNKNOWN = 'UNKNOWN',
INITING = 'INITING',
PAIRED = 'PAIRED',
CONNECTED = 'CONNECTED',
DISCONNECTED = 'DISCONNECTED',
REJECTED = 'REJECTED',
REQUEST = 'REQUEST',
CONNECTING = 'CONNECTING',
TXING = 'TXING',
}
export enum LEDGER_STATUS {
DISCONNECTED = 'DISCONNECTED',
CONNECTING = 'CONNECTING',
CONNECTED = 'CONNECTED',
}
export const LEDGER_STATUS_CHANGE_EVENT = 'LEDGER_STATUS_CHANGE_EVENT'
export const WC_STATUS_CHANGE_EVENT = 'WC_STATUS_CHANGE_EVENT'
export enum NetworkType {
MAINNET = 'mainnet',
TESTNET = 'testnet',
}
export type CombineNetworkType = NetworkType | AppChainType
export enum ButtonType {
DEFAULT = 'default',
PRIMARY = 'primary',
DANGER = 'danger',
}
export enum NearAccountIdSuffix {
MAINNET = '.near',
TESTNET = '.testnet',
}
export type iNotification = {
noti: Notification
isRead: boolean
}
export enum Currency {
USD = 'USD',
EUR = 'EUR',
CNY = 'CNY',
JPY = 'JPY',
}
export type CurrencyRate = {
[key in Currency]?: number
}
export interface ToastPayload {
type: ToastType
message: string
duration: number
}
export enum Chain {
NEAR = 'NEAR',
OCT = 'OCT',
}
export enum WalletSource {
MNEMONIC = 'MNEMONIC',
PRIVATE_KEY = 'PRIVATE_KEY',
}
export interface Wallet {
address: string
chain: Chain
alias?: string
networkType: CombineNetworkType
publicKey: string
isLedger?: boolean
customNetworkName?: string
avatar?: string
}
export interface CustomNetwork {
name: string
nodeUrl: string
type: NetworkType
chain: Chain
[key: string]: any
}
export interface Contact {
address: string
chain: Chain
alias: string
networkType: CombineNetworkType
avatar?: string
}
export interface SecureKeyStore {
privateKey?: string
publicKey: string
chain: Chain
networkType: CombineNetworkType
mnemonic?: string
address: string
}
export interface NewWalletSetup {
mnemonic: string
accountId: string
networkType: NetworkType
}
export interface AppChain {}
export interface OctTx {
amount: string
extrinsicId: string
fromId: string
id: string
timestamp: string
toId: string
}
export interface AppChainNode {
id: AppChainType
icon: ImageSourcePropType
name: string
rpc: {
mainnet?: string
testnet?: string
}
}
export interface CreateAccount {
accountId: string
publicKey: string
action?: string
}
export interface WCEventPayload {
type: WC_STATUS
payload: any
}
export interface WCRequestParams {
chainId: string
request: {
method: 'near_signAndSendTransaction' | 'near_signAndSendTransactions'
params: {
transactions: Transaction[]
}
}
}
export interface WCRequest {
id: number
topic: string
wallet: Wallet
method: string
txs: Transaction[]
verifyOwner?: { accountId: string; message: string }
}
export interface SettingItem {
icon: any
title: string
value?: any
noChevron?: boolean
onPress: () => void
}
export interface LedgerDevice {
id: string
isConnectable: boolean
localName: string
manufacturerData: any
name: string
mtu: number
overflowServiceUUIDs: any
rssi: number
serviceData: any
serviceUUIDs: string[]
solicitedServiceUUIDs: any
txPowerLevel: any
}
export interface EditorChoiceDapp {
title: string
oneliner: string
logo: string
website: string
banner: string
}
export interface ChainDapps {
edited: EditorChoiceDapp[]
catalogues: {
title: string
subtitle: string
items: Project[]
}[]
}
type NumberStr = string
export interface BaseNetwork {
name: string
nodeUrl: string
type: CombineNetworkType
[key: string]: string | number
}
export interface MarketItem extends Project {
subtitle: string
url: string
}
export interface MarketSection {
title: string
items: MarketItem[]
}
export enum TxType {
IN = 'IN',
OUT = 'OUT',
ADD_KEY = 'ADD_KEY',
DELETE_KEY = 'DELETE_KEY',
STAKE = 'STAKE',
FUNCTION_CALL = 'FUNCTION_CALL',
DEPLOY_CONTRACT = 'DEPLOY_CONTRACT',
CREATE_ACCOUNT = 'CREATE_ACCOUNT',
NFT = 'NFT',
UNKNOWN = 'UNKNOWN',
}
export interface BaseTx {
type: TxType
title: string
subtitle: string
hash: string
time: string | number
link: string
failed?: boolean
nft?: {
contractId: string
tokenId: string
}
}
export interface ChainMeta {
icon: ImageSourcePropType
chain: Chain
defaultNetworks: {
[key in CombineNetworkType]?: BaseNetwork
}
defaultNetworkType: CombineNetworkType
sources: WalletSource[]
default?: boolean
nativeTokens: Token[]
}
export interface BasePreviewSignParams {
[key: string]: any
}
export interface NFTItem {
token_id: string
owner_account_id: string
owner_id?: string
metadata: {
title: string
description: string
media: string
media_hash: string
copies: number
extra: string
reference: string
reference_hash: string
}
}
export interface NFTContractMetadata {
spec: string
name: string
symbol: string
icon: string
base_uri: string
reference: string
reference_hash: string
contract_account_id: string
}
export interface NFTsByCollection {
nfts: NFTItem[]
contract_metadata: NFTContractMetadata
block_timestamp_nanos: string
block_height: string
}