forked from SmartInvoiceXYZ/smart-invoice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
354 lines (327 loc) · 9.34 KB
/
Copy pathconfig.ts
File metadata and controls
354 lines (327 loc) · 9.34 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
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
import { toLower } from 'lodash';
import { Address, Chain, Hex } from 'viem';
import {
arbitrum,
base,
gnosis,
holesky,
mainnet,
optimism,
polygon,
sepolia,
} from 'viem/chains';
export const INVOICE_VERSION = 'smart-invoice-v0.1.0';
export type KnownResolverType =
| 'lexdao'
| 'kleros'
| 'smart-invoice'
| 'custom';
type ResolverWithoutAddress = {
id: KnownResolverType;
name: string;
logoUrl: string;
disclaimer?: string;
termsUrl: string;
};
type Tokens = {
[key: string]: {
decimals: number;
address: Hex;
};
};
export type Resolver = {
address: Address;
} & ResolverWithoutAddress;
export type NetworkConfig = {
SUBGRAPH: string;
WRAPPED_NATIVE_TOKEN: Address;
INVOICE_FACTORY: Address;
RESOLVERS: Partial<Record<KnownResolverType, Resolver>>;
TOKENS?: Tokens;
ZAP_ADDRESS?: Hex;
DAO_ADDRESS?: Hex;
TREASURY_ADDRESS?: Hex;
SPOILS_MANAGER?: Hex;
};
export type KlerosCourtData = {
id: number;
name: string;
link: string;
jurors_drawn: number;
reward: string;
safe_address: Address;
};
// @note: Kleros And Smart Invoice use the same safe address,
const SMART_INVOICE_ARBITRATION_SAFE = toLower(
'0x18542245cA523DFF96AF766047fE9423E0BED3C0',
) as Address;
// https://github.com/lexDAO/Arbitration/blob/master/README.md#resolution-of-any-arbitration-request
const LEXDAO_ARBITRATION_SAFE = {
[mainnet.id]: toLower(
'0x5B620676E28693fC14876b035b08CbB1B657dF38',
) as Address,
[arbitrum.id]: toLower(
'0x2f3F50ACc51b240cFf2a452Af050Cc601d3Adccf',
) as Address,
[polygon.id]: toLower(
'0xf8DBd458f841424e2fD5fBDf18A7dEA17eb2211D',
) as Address,
[gnosis.id]: toLower('0x153Fbf5da827903e030Dc317C4031755D74D508a') as Address,
};
export const KLEROS_GOOGLE_FORM = 'https://forms.gle/K3oMAzAb32G5SbpM9';
const LEXDAO_DATA: ResolverWithoutAddress = {
id: 'lexdao',
name: 'LexDAO',
logoUrl: '/assets/lex-dao.png',
termsUrl: 'https://docs.smartinvoice.xyz/arbitration/lexdao-arbitration',
};
const KLEROS_DATA: ResolverWithoutAddress = {
id: 'kleros',
name: 'Kleros',
disclaimer:
'Only choose Kleros if total invoice value is greater than 1000 USD',
logoUrl: '/assets/kleros.svg',
termsUrl: 'https://docs.smartinvoice.xyz/arbitration/kleros-arbitration',
};
const SMART_INVOICE_ARBITRATION_DATA: ResolverWithoutAddress = {
id: 'smart-invoice',
name: 'Smart Invoice In-house',
disclaimer:
'Only choose Smart Invoice In-house if invoice value is less than 1000 USD',
logoUrl: '/favicon.ico',
termsUrl:
'https://docs.smartinvoice.xyz/arbitration/smart-invoice-arbitration',
};
export const KLEROS_COURTS: Array<KlerosCourtData> = [
{
id: 1,
name: 'General Court',
link: 'https://klerosboard.com/100/courts/0',
jurors_drawn: 3,
reward: '13 DAI/USDC per juror',
safe_address: SMART_INVOICE_ARBITRATION_SAFE,
},
{
id: 2,
name: 'Solidity Court',
link: 'https://klerosboard.com/100/courts/13',
jurors_drawn: 2,
reward: '30 DAI/USDC per juror',
safe_address: SMART_INVOICE_ARBITRATION_SAFE,
},
{
id: 3,
name: 'Javascript Court',
link: 'https://klerosboard.com/100/courts/14',
jurors_drawn: 2,
reward: '30 DAI/USDC per juror',
safe_address: SMART_INVOICE_ARBITRATION_SAFE,
},
];
const STUDIO_ID = '78711';
const getSubgraphUrl = (subgraphId: string, versionLabel: string) =>
`https://api.studio.thegraph.com/query/${STUDIO_ID}/${subgraphId}/${versionLabel}`;
const chains: readonly [Chain, ...Chain[]] = [
mainnet,
gnosis,
polygon,
arbitrum,
optimism,
sepolia,
base,
holesky,
];
export const SUPPORTED_CHAIN_IDS = chains.map(chain => chain.id);
export type SupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
export type SupportedChain = (typeof chains)[number];
export const SUPPORTED_CHAINS = chains as [SupportedChain, ...SupportedChain[]];
export const NETWORK_CONFIG: Record<SupportedChainId, NetworkConfig> = {
[mainnet.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice', 'v0.0.3'),
WRAPPED_NATIVE_TOKEN: toLower(
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
) as Address,
INVOICE_FACTORY: toLower(
'0x5E14cF595e18F91170009946205f8BBa21b323ca',
) as Address,
RESOLVERS: {
lexdao: {
address: LEXDAO_ARBITRATION_SAFE[mainnet.id],
...LEXDAO_DATA,
},
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
[gnosis.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice-gnosis', 'v0.0.5'),
WRAPPED_NATIVE_TOKEN: toLower(
'0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
) as Address,
INVOICE_FACTORY: toLower(
'0xdDd96D43b0B2Ca179DCefA58e71798d0ce56c9c8',
) as Address,
RESOLVERS: {
lexdao: {
address: LEXDAO_ARBITRATION_SAFE[gnosis.id],
...LEXDAO_DATA,
},
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
[polygon.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice-polygon', 'v0.0.3'),
WRAPPED_NATIVE_TOKEN: toLower(
'0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
) as Address,
INVOICE_FACTORY: toLower(
'0x6dcF61a9170419f30e065A43540aa3663b837342',
) as Address,
RESOLVERS: {
lexdao: {
address: LEXDAO_ARBITRATION_SAFE[polygon.id],
...LEXDAO_DATA,
},
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
[arbitrum.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice-arbitrum', 'v0.0.3'),
WRAPPED_NATIVE_TOKEN: toLower(
'0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
) as Address,
INVOICE_FACTORY: toLower(
'0xb4CdeF4aa610C046864467592FaE456a58d3443a',
) as Address,
RESOLVERS: {
lexdao: {
address: LEXDAO_ARBITRATION_SAFE[arbitrum.id],
...LEXDAO_DATA,
},
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
[optimism.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice-optimism', 'v0.0.3'),
WRAPPED_NATIVE_TOKEN: toLower(
'0x4200000000000000000000000000000000000006',
) as Address,
INVOICE_FACTORY: toLower(
'0xF9822818143948237A60A1a1CEFC85D6F1b929Df',
) as Address,
RESOLVERS: {
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
[sepolia.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice-sepolia', 'v0.0.3'),
WRAPPED_NATIVE_TOKEN: toLower(
'0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
) as Address,
INVOICE_FACTORY: toLower(
'0x8227b9868e00B8eE951F17B480D369b84Cd17c20',
) as Address,
RESOLVERS: {
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
[base.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice-base', 'v0.0.3'),
WRAPPED_NATIVE_TOKEN: toLower(
'0x4200000000000000000000000000000000000006',
) as Address,
INVOICE_FACTORY: toLower(
'0xF9822818143948237A60A1a1CEFC85D6F1b929Df',
) as Address,
RESOLVERS: {
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
[holesky.id]: {
SUBGRAPH: getSubgraphUrl('smart-invoice-holesky', 'v0.0.3'),
WRAPPED_NATIVE_TOKEN: toLower(
'0x94373a4919B3240D86eA41593D5eBa789FEF3848',
) as Address,
INVOICE_FACTORY: toLower(
'0xE0986c3bdAB537fBeb7c94D0C5EF961d6d8bf63a',
) as Address,
RESOLVERS: {
kleros: {
address: SMART_INVOICE_ARBITRATION_SAFE,
...KLEROS_DATA,
},
'smart-invoice': {
address: SMART_INVOICE_ARBITRATION_SAFE,
...SMART_INVOICE_ARBITRATION_DATA,
},
},
},
};
export const IPFS_ENDPOINT = 'https://gateway.pinata.cloud';
export const ARWEAVE_ENDPOINT = 'https://arweave.net';
export function isSupportedChainId(
chainId: number | undefined,
): chainId is SupportedChainId {
if (!chainId) return false;
return chainId in NETWORK_CONFIG;
}
export const graphUrls = (chainId: SupportedChainId) =>
NETWORK_CONFIG[chainId].SUBGRAPH;
export const resolvers = (
chainId: SupportedChainId,
): Array<KnownResolverType> =>
Object.keys(NETWORK_CONFIG[chainId].RESOLVERS) as Array<KnownResolverType>;
export const resolverInfo = (chainId: SupportedChainId) =>
NETWORK_CONFIG[chainId].RESOLVERS;
export const wrappedNativeToken = (chainId: SupportedChainId) =>
NETWORK_CONFIG[chainId].WRAPPED_NATIVE_TOKEN;
export const invoiceFactory = (chainId: SupportedChainId) =>
NETWORK_CONFIG[chainId].INVOICE_FACTORY;