forked from youves-com/youves-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch-contract-metadata.ts
215 lines (190 loc) · 7.96 KB
/
fetch-contract-metadata.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
const fs = require('fs')
const { TezosToolkit } = require('@taquito/taquito')
const Tezos = new TezosToolkit('https://mainnet.smartpy.io')
const CONTRACTS_FILE = './src/contracts/contracts.ts'
const exportPrefix = 'export const contractInfo = '
const getDataForContracts = async (
old: Record<string, { script: Object; entrypoints: Object }>,
contracts: string[]
): Promise<Record<string, { script: Object; entrypoints: Object }>> => {
// TODO: Filter out contracts from obj that are no longer needed.
const obj: Record<string, { script: Object; entrypoints: Object }> = {}
for (let contract of contracts) {
if (old[contract]) {
obj[contract] = old[contract]
continue
}
try {
console.log('loading', contract)
const script: { code: any[]; storage: any[] } = await Tezos.rpc.getScript(contract)
const entrypoints = await Tezos.rpc.getEntrypoints(contract)
obj[contract] = {
script,
entrypoints
}
} catch (e) {
console.log(e)
throw new Error('ERROR')
}
}
return obj
}
const object: Record<string, { script: string; entrypoints: string }> = (() => {
try {
return JSON.parse(fs.readFileSync(CONTRACTS_FILE, 'utf-8').substr(exportPrefix.length))
} catch (e) {
console.log('err', e)
return {}
}
})()
const indexPage: string[] = [
'KT1XRPEPXbZK25r3Htzp2o1x7xdMMmfocKNW',
'KT1Xobej4mc6XgEjDoJoHtTKgbD1ELMvcQuL',
'KT1UDZNYC4twtgeN2WatoEjzjjANnRgsK3hD',
'KT1Lz5S39TMHEA7izhQn8Z1mQoddm6v1jTwH',
'KT1M8asPmVQhFG6yujzttGonznkghocEkbFk',
'KT1TMfRfmJ5mkJEXZGRCsqLHn2rgnV1SdUzb',
'KT1A1VNTvyqJYZN2FypF2kiTBPdoRvG9sCA7',
'KT1PL1YciLdwMbydt21Ax85iZXXyGSrKT2BE',
'KT1FFE2LC5JpVakVjHm5mM36QVp2p3ZzH4hH',
'KT1EtjRRCBC2exyCRXz8UfV7jz7svnkqi7di',
'KT1TnrLFrdemNZ1AnnWNfi21rXg7eknS484C',
'KT1ESueqJziqKEgoePd1FMemk5XDiKhjczd6',
'KT1FzcHaNhmpdYPNTgfb8frYXx7B5pvVyowu',
'KT1TFPn4ZTzmXDzikScBrWnHkoqTA7MBt9Gi',
'KT1Kvg5eJVuYfTC1bU1bwWyn4e1PRGKAf6sy',
'KT1BLLj2GZN6VuiM1Vg8LNsPWzoZTUa3mYqq',
'KT1Wqc19pqbYfzM3pVMZ35YdSxUvECwFfpVo',
'KT1B2GSe47rcMCZTRk294havTpyJ36JbgdeB',
'KT1EAw8hL5zseB3SLpJhBqPQfP9aWrWh8iMW',
'KT1H8sJY2VzrbiX4pYeUVsoMUd4iGw2DV7XH',
'KT19bkpis4NSDnt6efuh65vYxMaMHBoKoLEw',
'KT1KNbtEBKumoZoyp5uq6A4v3ETN7boJ9ArF',
'KT1Pcv7VbgSFFRU9ykc1dwGHM3VjfWmfZqfB',
'KT1M9rKvjNGdyHnrbxjrLhW9HCsAwtfY13Fn',
'KT1VjQoL5QvyZtm9m1voQKNTNcQLi5QiGsRZ',
'KT1WBLrLE2vG8SedBqiSJFm4VVAZZBytJYHc',
'KT18ePgHFBVBSLJD7uJoX2w5aZY3SvtV9xGP',
'KT1NFWUqr9xNvVsz2LXCPef1eRcexJz5Q2MH',
'KT1JeWiS8j1kic4PHx7aTnEr9p4xVtJNzk5b',
'KT1T974a8qau4xP3RAAWPYCZM9xtwU9FLjPS',
'KT1XvH5f2ja2jzdDbv6rxPmecZFU7s3obquN',
'KT1AVbWyM8E7DptyBCu4B5J5B7Nswkq7Skc6',
'KT1Xbx9pykNd38zag4yZvnmdSNBknmCETvQV',
'KT1HxgqnVjGy7KsSUTEsQ6LgpD5iKSGu7QpA',
'KT1Txa8RdTnNjX7E3RqVzUNA5ZyHVgHB96ta',
'KT1LQcsXGpmLXnwrfftuQdCLNvLRLUAuNPCV',
'KT1BjNkpfeb5gWQqMTB8Px1z3EXE4F3Tpkat',
'KT1E45AvpSr7Basw2bee3g8ri2LK2C2SV2XG',
'KT1UyfqcrxAmBqTbaVGbVUDSy6yLUxCUYmEw',
'KT1UZcNDxTdkn33Xx5HRkqQoZedc3mEs11yV', // Unified Staking
'KT18bG4ctcB6rh7gPEPjNsWF8XkQXL2Y1pJe', // Unified Savings uUSD
'KT1WT8hZsixALTmxcM3SDzCyh4UF8hYXVaUb', // Unified Savings uBTC
'KT1H41VCk8FgskYy4RbLXH8Fwt83PJ5MNvno',
'KT1CP1C8afHqdNfBsSE3ggQhzM2iMHd4cRyt',
'KT1TCLpFRB6xiRmeupUCz9yFf7JiEvbLe1aS',
'KT1J217QyWoPSE8EtAySMyJjr8ptTsakBszP',
'KT1CeZvxMXqEjf2tQ7a5Ex7S9wVRLJWYaSUu',
'KT1KpFkAKgrAJNXZxhahFaTduTAoEc8jFpmQ',
'KT1DHndgk8ah1MLfciDnCV2zPJrVbnnAH9fd',
'KT1H4h1VunWkVE9Cuq1QDVy9xRNLBSbqXsr9',
'KT1DP7rtzCGotqwgmZP8vViTVGz22mBwGGTT',
'KT1F6Amndd62P8yySM5NkyF4b1Kz27Ft4QeT',
'KT1G6RzVX25YnoU55Xb7Vve3zvuZKmouf24a',
'KT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fKMY8PZLnEyUSH8',
'KT18x66448Gt3kYYkfvx4Cg2dP9cRPfjQwVv', //ubtc tzbtc 0%
'KT19esJWnECAyezS8w9B3SBBCJMeyFgkBE6L', //uusd xtz 0% options
'KT1AnDFRcdB652Jy5JFtmu7SampSPAzDkK7g', //uxtz usdt
'KT1BUR5mjwBWzojKRqWrng8ASBh3N3LLV7NM', //uctz usdt options
'KT1ByNrcyDxYLmamuJbeFJukYkLJaZ1W86Yr', //uxtz sirs
'KT1C3T98TqCm38cHPauZ4SopkQ4torCsxgab', //youves DAO
'KT1CHL9XVrt3Avr1mHkCiZBANEeJzbUSGqGB', //uxtz sirs options
'KT1DnPwdvntBac7xFmdLqNakKcLHVjYfW1WU', //ubtc tzbtc options
'KT1GL6CBm93edDHogUVQzasUd6m7384eZk3J', //uctz xtz options
'KT1H2514Wb6G38fmgU3vpAwkWEpFC9sq7HPH', //uusd sirs 0%
'KT1H5b7LxEExkFd2Tng77TfuWbM5aPvHstPr', //ctez XTZ swap (non youves)
'KT1HNpkQQo5QAVC4yywN9fPNycBZaaB5c4oy', //uusd sirs 0% options
'KT1Jf2UHSo6PbBfKYZiCzDq5UpeTKDQPeCJb', //ubtc tzbtc 0%
'KT1KShHvxW69YukaGetdgYRTw31d9BX8ijfF', //uxtz savings pool
'KT1Mf9Nr1KyGC6gUz9pGQnngzWbbZ6thShvc', //uxtz xtz
'KT1NC8PcGG6QR6V2AezQTwd8xjgorDzkCzYy', //ubtc sirs 0%
'KT1PuCU5UAoaX2Hjcns2SEmJWBC34tfLjzaS', //oracle 1:1
'KT1PvKziQx7pJhfr3FdvkhMPwCwLxjd32HkZ', //XTZUSDT oracle
'KT1SEjPmaeVPMu4Ep94ggF3tLqzFM83T3pBd', //ubtc sirs 0%
'KT1TcCSR24TmDvwTfHkyWbwMB111gtNYxEcA', //uusd tez 0%
'KT1TSwSAU1qUyRFYBv6ix5YzqLBparxJ3FAk', //BTCXTZ proxy oracle
'KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5', //Sirius Dex (non youves)
'KT1WgguedKZWucrdRKQXaRECEPMZennaVPck', //uxtz/xtz flat curve pool
'KT1XH5rKSd6Ae3DAMYi26gEZP1gxAoQRYRfS' //ubtc tzbtc
]
const earnPage = [
'KT1TkNadQ9Cw5ZNRyS4t9SKmUbmAMkqY8bkV',
'KT1KGfEyxBeCU873RfuwrU1gy8sjC1s82WZV',
'KT1HaWDWv7XPsZ54JbDquXV6YgyazQr9Jkp3',
'KT1JFsKh3Wcnd4tKzF6EwugwTVGj3XfGPfeZ',
'KT1Ug9wWbRuUs1XXRuK11o6syWdTFZQsmvw3',
'KT1Goz5Dsi8Hf7fqjx5nSEcjp6osD9ufECB2',
'KT1W78rDHfwp3CKev7u7dWRJTBqLdwYVcPg9',
'KT1RLGwCgeq2ab92yznQnJinpqy9kG13dFh2',
'KT18x3gGRMKyhzcBnKYSRrfqjnzu4fPE1Lzy',
'KT1CuqpjqPPvcZCrvzJunCvHvPaujASdmFJZ',
'KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn',
'KT1NZt7NTYs7m3VhB8rrua7WwVQ9uhKgpgCN',
'KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV',
'KT1Toztq42271zT2wXDnu2hFVVdJJ8qWrETu',
'KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9'
]
const swapPage = ['KT1Exm6UTCNEbBHANZ7S53t7QN8NJFwAytxg', 'KT18fp5rcTW7mbWDmzFwjLDUhs5MeJmagDSZ']
// Add contract addresses here
// De-duplicate all entries
const allContracts: Set<string> = new Set()
indexPage.forEach((contract) => allContracts.add(contract))
earnPage.forEach((contract) => allContracts.add(contract))
swapPage.forEach((contract) => allContracts.add(contract))
const ghostnetContracts = [
'KT1JsCFDiQpFPRwgRkKRPfyxyEE4M7b1tTyq',
'KT1VsjbfCo3PUm4ePzG59Zy7Rxwk6wecCMQy',
'KT1CrNkK2jpdMycfBdPpvTLSLCokRBhZtMq7',
'KT1XXUzvauzUBz3c7YuKSF5x5aBjRyVa4tXi',
'KT19uLXFNyvGuiKUwkoh4a5Rz3xP5dDYQf5i',
'KT1J4CiyWPmtFPXAjpgBezM5hoVHXHNzWBHK',
'KT1T7Rx3uzj5wwvFVrCnHxo64RvFtS8awJK7',
'KT1B2JKsRMGocer8jVLGmZdJshEaReyNpEGd',
'KT1U7vd5DLjFGuK94Q4jUqPzzQdsyWA38DUH',
'KT1XXUzvauzUBz3c7YuKSF5x5aBjRyVa4tXi',
'KT1PFrFXJV484NtSta3UCnNGzRDnymdz2SPE',
'KT1Q4qRd8mKS7eWUgTfJzCN8RC6h9CzzjVJb'
]
const allContractsArray = Array.from(allContracts.values())
console.log(`Storing ${allContractsArray.length} contracts`)
getDataForContracts(object, allContractsArray).then((newObject) => {
console.log(newObject)
fs.writeFileSync(CONTRACTS_FILE, `${exportPrefix}${JSON.stringify(newObject)}`)
})