/
unlockTypes.ts
304 lines (273 loc) · 6.49 KB
/
unlockTypes.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
// This file contains type definitions for the various kinds of data that we use
// throughout unlock-app.
import type { BigNumber } from 'ethers'
// A bug in eslint causes it to think that this exported enum is "unused". So
// disable eslint for that declaration until they fix it. TODO: follow up on this.
/* eslint-disable no-unused-vars */
export enum TransactionType {
LOCK_CREATION = 'LOCK_CREATION',
KEY_PURCHASE = 'KEY_PURCHASE',
WITHDRAWAL = 'WITHDRAWAL',
UPDATE_KEY_PRICE = 'UPDATE_KEY_PRICE',
}
/* eslint-enable no-unused-vars */
/* eslint-disable no-unused-vars */
export enum TransactionStatus {
SUBMITTED = 'submitted',
PENDING = 'pending',
MINED = 'mined',
STALE = 'stale',
FAILED = 'failed',
NONE = '', // for testing purposes
}
/* eslint-enable no-unused-vars */
export interface NetworkDeploy {
unlockAddress: string
startBlock: number
}
export interface Token {
name: string
address: string
symbol: string
decimals: number
coingecko?: string
coinbase?: string
mainnetAddress?: string
wrapped?: string
featured?: boolean
}
export enum HookType {
CUSTOM_CONTRACT = 'CUSTOM_CONTRACT',
PASSWORD = 'PASSWORD',
PROMOCODE = 'PROMOCODE',
PROMO_CODE_CAPPED = 'PROMO_CODE_CAPPED',
CAPTCHA = 'CAPTCHA',
GUILD = 'GUILD',
GITCOIN = 'GITCOIN',
}
export const HooksName = [
'onKeyPurchaseHook',
'onKeyCancelHook',
'onValidKeyHook',
'onTokenURIHook',
'onKeyTransferHook',
'onKeyExtendHook',
'onKeyGrantHook',
] as const
export type HookName = (typeof HooksName)[number]
export interface Hook {
id: HookType
name: string
address: string
description?: string
}
// info about the bridge are available at
// https://docs.connext.network/resources/deployments
export interface NetworkBridgeConfig {
domainId: number
connext: string
modules?: {
connextMod?: string
delayMod?: string
}
}
export interface NetworkConfig {
id: number
featured: boolean
name: string
chain: string
provider: string
publicProvider: string
unlockAddress: string
multisig?: string
keyManagerAddress?: string
universalCard?: {
cardPurchaserAddress: string
stripeDestinationNetwork: string
stripeDestinationCurrency: string
}
publicLockVersionToDeploy: number
subgraph: {
endpoint: string
// refers to thegraph services list : https://thegraph.com/docs/en/developing/supported-networks/
networkName?: string // network slug used by the graph
studioName?: string
}
uniswapV3?: Partial<{
subgraph: string
factoryAddress: string
quoterAddress: string
oracle: string
universalRouterAddress: string
positionManager: string
}>
swapPurchaser?: string
unlockOwner?: string
unlockDaoToken?: {
address: string
mainnetBridge?: string
}
explorer?: {
name: string
urls: {
base: string
address(address: string): string
transaction(hash: string): string
token(address: string, owner: string): string
}
}
opensea?: {
tokenUrl: (lockAddress: string, tokenId: string) => string | null
collectionUrl?: (lockAddress: string) => string
profileUrl?: (address: string) => string
}
blockScan?: {
url?: (address: string) => string
}
governanceBridge?: NetworkBridgeConfig
isTestNetwork?: boolean
erc20?: {
symbol: string
address: string
} | null
maxFreeClaimCost?: number
nativeCurrency: Omit<Token, 'address'>
startBlock?: number
previousDeploys?: NetworkDeploy[]
description: string
url?: string
faucet?: string
tokens?: Token[]
hooks?: Partial<Record<HookName, Hook[]>>
fullySubsidizedGas?: boolean
}
export interface NetworkConfigs {
[networkId: string]: NetworkConfig
}
export interface ContractAbi {
contractName: string
abi: Array<{}>
bytecode: string
deployedBytecode: string
compiler: string
schemaVersion: string
updatedAt: string
}
export interface Transaction {
status: TransactionStatus
confirmations: number
hash: string
type: TransactionType
blockNumber: number
createdAt?: Date
to?: string
for?: string
from?: string
lock?: string
name?: string
key?: string // TODO: tighten up our types, hopefully we won't have too many
// optional properties.
}
// Analogous to the transactions in Redux
export interface Transactions {
[hash: string]: Transaction
}
export interface Account {
address: string
balance: string // TODO: Stricter balance type (enforce currency, precision)
}
export interface Network {
name: number // TODO: This is very misleading, change property name to id
}
export interface ChainExplorerURLBuilders {
[site: string]: (_address: string) => string
}
export enum KeyStatus {
NONE = 'none',
CONFIRMING = 'confirming',
CONFIRMED = 'confirmed',
EXPIRED = 'expired',
VALID = 'valid',
SUBMITTED = 'submitted',
PENDING = 'pending',
FAILED = 'failed',
}
export interface RawLock {
name: string
address: string
keyPrice: string
expirationDuration: number
currencyContractAddress: string | null
asOf?: number
maxNumberOfKeys?: number
outstandingKeys?: number
balance?: string
owner?: string
}
export interface Lock {
name: string
address: string
keyPrice: string
expirationDuration: number
key: Key
currencyContractAddress: string | null
currencyDecimals?: number | null
currencySymbol?: string | null
asOf?: number
maxNumberOfKeys?: number
outstandingKeys?: number
balance?: string
owner?: string
}
// Mapping if currency: amount
export interface Balance {
[currency: string]: string
}
export interface Locks {
[address: string]: Lock
}
export interface RawLocks {
[address: string]: RawLock
}
export interface Key {
expiration: number
transactions: Transaction[]
status: string
confirmations: number
owner: string | null
lock: string
}
export interface PurchaseKeyRequest {
lock: string // lock address
extraTip: string // extra value to add in addition to key price
}
export interface NetworkNames {
[key: number]: string[]
}
// Keys exactly as they come out of Web3Service
export interface KeyResult {
lock: string
owner: string
expiration: number
}
export type KeyResults = { [key: string]: KeyResult }
export interface UserMetadata {
publicData?: {
[key: string]: string
}
protectedData?: {
[key: string]: string
}
}
export interface UnlockUniswapRoute {
swapCalldata?: string
value: string
amountInMax: BigNumber
swapRouter: string
quote: any
trade: any
convertToQuoteToken: any
quoteGasAdjusted: any
estimatedGasUsedUSD: any
}
export type UnlockNetworks = number