-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgroupChecker.html
332 lines (316 loc) · 10.9 KB
/
groupChecker.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Group Checker</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
margin: 0;
font-family: 'Inter', Helvetica, Arial, sans-serif;
background: #ffffff;
color: #333;
line-height: 1.3;
}
header {
background: #5C49E4;
color: #fff;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
font-weight: 600;
font-size: 1.5rem;
}
p {
margin: 0.5rem 0 0;
font-weight: 400;
}
.container {
max-width: 800px;
margin: 40px auto;
padding: 0 20px;
}
label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
}
input {
padding: 10px;
width: 100%;
max-width: 600px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
button {
margin-top: 10px;
padding: 10px 20px;
background: #5C49E4;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
font-weight: 600;
}
button:hover {
background: #4A39CC;
}
#result {
margin-top: 20px;
padding: 20px;
border-radius: 8px;
background: #fafafa;
border: 1px solid #eee;
min-height: 200px;
}
.info {
margin: 0.3rem 0;
line-height: 1.3;
}
.address-link {
color: #5C49E4;
text-decoration: none;
font-weight: 500;
cursor: pointer;
}
.address-link:hover {
text-decoration: underline;
}
table {
border-collapse: collapse;
margin-top: 10px;
width: 100%;
font-size: 0.95rem;
background: #fff;
border-radius: 6px;
overflow: hidden;
border: 1px solid #eee;
}
th, td {
text-align: left;
padding: 10px;
white-space: nowrap;
}
th {
background: #f9f9fc;
font-weight: 600;
border-bottom: 1px solid #eee;
}
tr:nth-child(even) {
background: #fafafa;
}
tr:hover td {
background: #f3f3f7;
}
td {
border-bottom: 1px solid #eee;
}
strong {
font-weight: 600;
}
.loader {
border: 4px solid #f3f3f3;
border-top: 4px solid #5C49E4;
border-radius: 50%;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
display: inline-block;
vertical-align: middle;
margin-left: 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<header>
<h1>Group Checker</h1>
<p>Enter one or more group addresses (comma separated) to see group details and associated ERC20 token data.</p>
</header>
<div class="container">
<label for="groupInput">Group Addresses:</label>
<!-- Prepopulated with your specified group addresses -->
<input type="text" id="groupInput" value="0xdca9d42a96ecf8ede1e6920bec08870bba69600e, 0x81f5c609269b5be123282f282a88282b41f3005e, 0xc164522ebc7e6a8b4b08878cf9e330cfebf4850a, 0x89308E1F7eFD05F7d57548D4b722feB5EA560b49, 0xc9A2bDC6D3b6837C1C6357E1D00232E50268A7B6, 0x60d3be9f084b4e6d81587b517b202da5ae59cc62, 0x79b7c28088a5d35e23e63236f98ea93aa276cf1a" />
<button id="checkButton">Check Groups</button>
<div id="result"></div>
</div>
<!-- Ethers.js UMD build -->
<script>
/*********************
* Profile Lookup Functionality
*********************/
async function getProfileName(address) {
try {
console.log("Fetching profile for address:", address);
const queryAddress = address.toLowerCase();
const url = `https://rpc.aboutcircles.com/profiles/search?address=${queryAddress}`;
console.log("Request URL:", url);
const response = await fetch(url);
if (!response.ok) {
console.error("HTTP error", response.status, response.statusText);
return "No name";
}
const data = await response.json();
console.log("Profile response for", address, data);
if (Array.isArray(data)) {
const profile = data.find(entry => entry.address.toLowerCase() === queryAddress);
return profile?.name || "No name";
}
return "No name";
} catch (error) {
console.error("Error fetching profile for", address, error);
return "No name";
}
}
/*********************
* Group Checker Logic
*********************/
// GroupInfoGetter contract ABI – note the returned tuple structure.
const groupGetterABI = [
"function getGroupsInfo(address[] calldata groupAddresses) external view returns (tuple(address owner, address service, address mintHandler, address redemptionHandler, uint256 minimalDeposit, address feeCollection, address staticERC20, address demurragedERC20, uint256 staticTotalSupply, uint256 demurragedTotalSupply)[] memory)"
];
// Deployed GroupInfoGetter address
const groupGetterAddress = "0xD4de76d83239ef8D2257C966850fE6Cf19f4b434";
// Initialize ethers provider (Gnosis chain)
const provider = new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/gnosis");
const groupGetterContract = new ethers.Contract(groupGetterAddress, groupGetterABI, provider);
const checkButton = document.getElementById("checkButton");
const resultDiv = document.getElementById("result");
const groupInput = document.getElementById("groupInput");
async function checkGroups(input) {
// Clear previous results
resultDiv.innerHTML = "";
// Parse addresses (split by comma) and trim spaces
const addresses = input.split(",")
.map(addr => addr.trim())
.filter(addr => addr !== "");
// Validate each address
for (let addr of addresses) {
if (!ethers.utils.isAddress(addr)) {
resultDiv.innerHTML = `<p style='color:red;'>Invalid address detected: ${addr}</p>`;
return;
}
}
// Show loader
const loader = document.createElement("div");
loader.className = "loader";
const loadingText = document.createElement("span");
loadingText.textContent = "Fetching data...";
resultDiv.appendChild(loadingText);
resultDiv.appendChild(loader);
try {
// Call the getter function on-chain
const groups = await groupGetterContract.getGroupsInfo(addresses);
// Remove loader
resultDiv.innerHTML = "";
// Build a table to display group info
let html = `
<table>
<thead>
<tr>
<th>Group Address</th>
<th>Owner</th>
<th>Service</th>
<th>Mint Handler</th>
<th>Redemption Handler</th>
<th>Minimal Deposit</th>
<th>Fee Collection</th>
<th>Demurraged ERC20</th>
<th>Demurraged Total Supply</th>
<th>Static ERC20</th>
<th>Static Total Supply</th>
</tr>
</thead>
<tbody>
`;
// Iterate over the results. The order corresponds to the input addresses.
for (let i = 0; i < addresses.length; i++) {
const groupAddress = addresses[i];
const info = groups[i];
html += `
<tr>
<td>
<span class="address-link" data-address="${groupAddress}">${groupAddress}</span>
<br>
<small class="profile-name" data-address="${groupAddress}">Loading name...</small>
</td>
<td>
<span class="address-link" data-address="${info.owner}">${info.owner}</span>
<br>
<small class="profile-name" data-address="${info.owner}">Loading name...</small>
</td>
<td>
<span class="address-link" data-address="${info.service}">${info.service}</span>
</td>
<td>
<span class="address-link" data-address="${info.mintHandler}">${info.mintHandler}</span>
<br>
<small class="profile-name" data-address="${info.mintHandler}">Loading name...</small>
</td>
<td>
<span class="address-link" data-address="${info.redemptionHandler}">${info.redemptionHandler}</span>
<br>
<small class="profile-name" data-address="${info.redemptionHandler}">Loading name...</small>
</td>
<td>${info.minimalDeposit}</td>
<td>
<span class="address-link" data-address="${info.feeCollection}">${info.feeCollection}</span>
</td>
<td>
<span class="address-link" data-address="${info.staticERC20}">${info.staticERC20}</span>
<br>
<small class="profile-name" data-address="${info.staticERC20}">Loading name...</small>
</td>
<td>${ethers.utils.formatUnits(info.staticTotalSupply, 18)}</td>
<td>
<span class="address-link" data-address="${info.demurragedERC20}">${info.demurragedERC20}</span>
<br>
<small class="profile-name" data-address="${info.demurragedERC20}">Loading name...</small>
</td>
<td>${ethers.utils.formatUnits(info.demurragedTotalSupply, 18)}</td>
</tr>
`;
}
html += `</tbody></table>`;
resultDiv.innerHTML = html;
// Update each "profile-name" cell with the actual name fetched from the API
const nameCells = document.querySelectorAll(".profile-name");
for (const cell of nameCells) {
const addr = cell.getAttribute("data-address");
// Skip the zero address
if (addr === "0x0000000000000000000000000000000000000000") {
cell.textContent = "None";
} else {
const profileName = await getProfileName(addr);
cell.textContent = profileName;
}
}
} catch (error) {
console.error(error);
resultDiv.innerHTML = `<p style='color:red;'>Error: ${error.message}</p>`;
}
}
checkButton.addEventListener("click", async () => {
const input = groupInput.value.trim();
await checkGroups(input);
});
// When clicking on any displayed address, set it as the input and re-run the check.
resultDiv.addEventListener("click", async (e) => {
if (e.target.classList.contains("address-link")) {
const addr = e.target.getAttribute("data-address");
groupInput.value = addr;
await checkGroups(addr);
}
});
</script>
</body>
</html>