-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy pathDeepLinkTypes.ts
More file actions
191 lines (169 loc) · 4.42 KB
/
Copy pathDeepLinkTypes.ts
File metadata and controls
191 lines (169 loc) · 4.42 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
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
/*
* All Edge deep-linking features are available through the `edge://`
* protocol. This protocol comes in three flavors, which are fully equivalent:
*
* - edge://<type>/...
* - airbitz://<type>/...
* - https://deep.edge.app/<type>/...
* - https://dp.edge.app/<type>/...
*
* The `edge://` protocol supports the following link types:
*
* - edge: Edge login
* - pay: Payment request
* - plugin: GUI plugin deep link
* - promotion: Activate a promotion code
* - recovery: Password recovery
* - swap: Crypto-to-crypto swap
* - x-callback-url: Address request
*
* The `edge://` protocol is the preferred way to link into the application,
* but Edge also supports some feature-specific https domains:
*
* - https://dl.edge.app/... = edge://promotion/...
* - https://dl.edge.app/?af=... = edge://promotion/...
*
* `deep.edge.app` URLs may also carry an `?af=<installerId>` query parameter.
* When present alongside another payload (e.g. a `pay` private-key URI), the
* deep link resolves to an `affiliate` wrapper that activates the promotion
* and then delegates to the inner link.
*
* We also support some legacy prefixes (but don't use these):
*
* - edge-ret://plugins/simplex/... = edge://plugin/simplex/...
* - edge-ret://x-callback-url/... = edge://x-callback-url/...
* - airbitz-ret://x-callback-url/... = edge://x-callback-url/...
*
* Besides the edge:// protocol, there are also various coin-specific URI
* protocols like `bitcoin:`, which we just pass through as "other".
*/
import { asValue } from 'cleaners'
import type { EdgeTokenId } from 'edge-core-js'
import type {
FiatDirection,
FiatPaymentType
} from '../plugins/gui/fiatPluginTypes'
import type { AppParamList } from './routerTypes'
export interface AztecoLink {
type: 'azteco'
uri: string
}
export interface PaymentProtoLink {
type: 'paymentProto'
uri: string
}
export interface EdgeLoginLink {
type: 'edgeLogin'
lobbyId: string
}
export interface PasswordRecoveryLink {
type: 'passwordRecovery'
passwordRecoveryKey: string
}
export interface PluginLink {
type: 'plugin'
pluginId: string
path: string
query: Record<string, string | null>
}
export interface FiatPluginLink {
type: 'fiatPlugin'
pluginId: string
direction?: FiatDirection
providerId?: string
paymentType?: FiatPaymentType
}
export interface FiatProviderLink {
type: 'fiatProvider'
direction: FiatDirection
providerId: string
path: string
query: Record<string, string | null>
uri: string
}
export interface PromotionLink {
type: 'promotion'
installerId?: string
}
export interface PriceChangeLink {
type: 'price-change'
pluginId: string
body: string // Human-readable message
}
export interface MarketingLink {
type: 'marketing'
campaignId: string // Correlates notification opens to a marketing campaign
link?: DeepLink // Optional navigation target parsed from the payload URL
}
export interface RampLink {
type: 'ramp'
direction: FiatDirection
providerId: string
path: string
query: Record<string, string | null>
uri: string
}
export interface RewardsLink {
type: 'rewards'
pluginId: string
tokenId: EdgeTokenId
}
export interface RequestAddressLink {
type: 'requestAddress'
assets: Array<{ nativeCode: string; tokenCode: string }>
post?: string // Either post or redir must be specified
redir?: string
payer?: string
}
export interface SwapLink {
type: 'swap'
// We may eventually add query parameters to pre-populate currencies.
}
export interface WalletConnectLink {
type: 'walletConnect'
uri: string
}
export interface NoopLink {
type: 'noop'
}
export interface SceneLink {
type: 'scene'
sceneName: keyof AppParamList
query: AppParamList[keyof AppParamList]
}
export const asModalNames = asValue('fundAccount', 'test')
export type ModalNames = ReturnType<typeof asModalNames>
export interface ModalLink {
type: 'modal'
modalName: ModalNames
}
export interface AffiliateLink {
type: 'affiliate'
installerId: string
link: DeepLink
}
export type DeepLink =
| AffiliateLink
| AztecoLink
| SceneLink
| EdgeLoginLink
| FiatPluginLink
| FiatProviderLink
| MarketingLink
| ModalLink
| NoopLink
| PasswordRecoveryLink
| PaymentProtoLink
| PluginLink
| PriceChangeLink
| PromotionLink
| RequestAddressLink
| SwapLink
| WalletConnectLink
| RampLink
| RewardsLink
| {
type: 'other'
protocol: string // Without the ':'
uri: string
}