Skip to content

Commit a0c6030

Browse files
authored
Merge pull request #2 from sourcifyeth/staging
Release verify.sourcify.dev v1
2 parents ffc8339 + 0ae11ad commit a0c6030

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2168
-614
lines changed

.env.build.main

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
VITE_SOURCIFY_SERVER_URL=https://sourcify.dev/server
33

44
# Sourcify repository URL for viewing verified contracts
5-
VITE_SOURCIFY_REPO_URL=https://repo.sourcify.dev
5+
VITE_SOURCIFY_REPO_URL=https://repo.sourcify.dev
6+
7+
VITE_ENV=production

.env.build.staging

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ VITE_SOURCIFY_SERVER_URL=https://staging.sourcify.dev/server
33

44
# Sourcify repository URL for viewing verified contracts
55
VITE_SOURCIFY_REPO_URL=https://repo.staging.sourcify.dev
6+
7+
VITE_ENV=staging

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
if: github.ref == 'refs/heads/main'
4848
run: cp .env.build.main .env
4949

50+
- name: Set git commit hash
51+
run: echo -e "\nVITE_GIT_COMMIT=$(git rev-parse --short HEAD)" >> .env
52+
5053
- name: Build
5154
run: npm run build
5255

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ npm install
5454
# Create .env file with custom server URLs
5555
VITE_SOURCIFY_SERVER_URL=https://sourcify.dev/server
5656
VITE_SOURCIFY_REPO_URL=https://repo.sourcify.dev
57+
VITE_ENV=development
5758
```
5859

5960
### Development

app/app.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@ html,
3636
body {
3737
@apply bg-gray-100;
3838
}
39+
40+
/* Make all buttons and checkboxes have pointer cursor by default */
41+
button {
42+
cursor: pointer;
43+
}
44+
45+
input[type="checkbox"] {
46+
cursor: pointer;
47+
}
48+
49+
/* Add pointer cursor to label elements that have an input checkbox as a child */
50+
label:has(> input[type="checkbox"]) {
51+
cursor: pointer;
52+
}
53+
54+
select {
55+
cursor: pointer;
56+
}

app/components/ChainSelect.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function ChainSelect({ value, handleChainIdChange, className = ""
5757
return (
5858
<div ref={dropdownRef} className="relative">
5959
<div
60-
className={`${className} flex items-center justify-between cursor-pointer border border-gray-300 rounded-md px-3 py-2 bg-white hover:border-cerulean-blue-300 focus:outline-none focus:ring-2 focus:ring-cerulean-blue-500 focus:border-cerulean-blue-500 shadow-sm`}
60+
className={`${className} flex items-center justify-between border border-gray-300 rounded-md px-3 py-2 bg-white hover:border-cerulean-blue-300 focus:outline-none focus:ring-2 focus:ring-cerulean-blue-500 focus:border-cerulean-blue-500 shadow-sm cursor-pointer`}
6161
onClick={() => setIsOpen(!isOpen)}
6262
>
6363
<span className="truncate text-gray-900">
@@ -93,17 +93,19 @@ export default function ChainSelect({ value, handleChainIdChange, className = ""
9393
<div
9494
key={chain.chainId}
9595
className={`px-4 py-2 text-sm ${
96-
chain.supported
97-
? "cursor-pointer hover:bg-cerulean-blue-100"
98-
: "cursor-not-allowed"
99-
} ${
100-
value === chain.chainId.toString() ? "bg-cerulean-blue-100" : ""
101-
} ${!chain.supported ? "text-gray-400" : "text-gray-900"}`}
102-
onClick={chain.supported ? () => {
103-
handleChainIdChange(chain.chainId.toString());
104-
setIsOpen(false);
105-
setSearchTerm("");
106-
} : undefined}
96+
chain.supported ? "hover:bg-cerulean-blue-100 cursor-pointer" : "cursor-not-allowed"
97+
} ${value === chain.chainId.toString() ? "bg-cerulean-blue-100" : ""} ${
98+
!chain.supported ? "text-gray-400" : "text-gray-900"
99+
}`}
100+
onClick={
101+
chain.supported
102+
? () => {
103+
handleChainIdChange(chain.chainId.toString());
104+
setIsOpen(false);
105+
setSearchTerm("");
106+
}
107+
: undefined
108+
}
107109
>
108110
{chain.title || chain.name} ({chain.chainId})
109111
{!chain.supported && <span className="text-gray-500 text-xs"> - verification deprecated</span>}

app/components/PageLayout.tsx

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { ReactNode } from "react";
22
import { useChains } from "../contexts/ChainsContext";
33
import { Tooltip } from "react-tooltip";
4+
import { useServerConfig } from "~/contexts/ServerConfigContext";
5+
import { removeCurrentServerUrl } from "../utils/serverStorage";
46

57
interface PageLayoutProps {
68
children: ReactNode;
@@ -11,23 +13,48 @@ interface PageLayoutProps {
1113

1214
export default function PageLayout({ children, maxWidth = "max-w-4xl", title, subtitle }: PageLayoutProps) {
1315
const { loading, error, refetch } = useChains();
16+
const { serverUrl, setServerUrl, getDefaultServerUrls, setCustomServerUrls } = useServerConfig();
17+
18+
const handleResetServerSettings = () => {
19+
// Clear custom server URLs
20+
setCustomServerUrls([]);
21+
22+
// Reset to default server URL
23+
const defaultUrls = getDefaultServerUrls();
24+
setServerUrl(defaultUrls[0]);
25+
26+
// Clear from localStorage
27+
removeCurrentServerUrl();
28+
29+
// Refetch after reset
30+
refetch();
31+
};
1432

1533
const renderHeader = () => {
1634
if (!title && !subtitle) {
1735
return null;
1836
}
37+
38+
const envPrefix =
39+
import.meta.env.VITE_ENV && import.meta.env.VITE_ENV !== "production"
40+
? `(${import.meta.env.VITE_ENV} environment) `
41+
: "";
42+
1943
return (
20-
<div className="text-center p-8 border-b border-gray-200">
21-
<h1 className="text-3xl font-semibold text-gray-900 tracking-tight">{title}</h1>
22-
<p className="max-w-2xl mx-auto text-base text-gray-600">{subtitle}</p>
44+
<div className="text-center p-4 md:p-8 border-b border-gray-200">
45+
<h1 className="text-2xl md:text-3xl font-semibold text-gray-900 tracking-tight">{title}</h1>
46+
<p className="max-w-2xl mx-auto text-sm md:text-base text-gray-600">
47+
{envPrefix}
48+
{subtitle}
49+
</p>
2350
</div>
2451
);
2552
};
2653

2754
const renderContent = () => {
2855
if (loading) {
2956
return (
30-
<div className="text-center p-8">
57+
<div className="text-center p-4 md:p-8">
3158
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-cerulean-blue-500 mx-auto"></div>
3259
<p className="mt-4 text-gray-600">Loading supported chains...</p>
3360
</div>
@@ -36,7 +63,7 @@ export default function PageLayout({ children, maxWidth = "max-w-4xl", title, su
3663

3764
if (error) {
3865
return (
39-
<div className="text-center p-8">
66+
<div className="text-center p-4 md:p-8">
4067
<div className="text-light-coral-500 mb-4">
4168
<svg className="mx-auto h-12 w-12" fill="none" viewBox="0 0 24 24" stroke="currentColor">
4269
<path
@@ -47,14 +74,23 @@ export default function PageLayout({ children, maxWidth = "max-w-4xl", title, su
4774
/>
4875
</svg>
4976
</div>
50-
<h3 className="text-lg font-medium text-gray-900 mb-2">Failed to load networks</h3>
77+
<h3 className="text-lg font-medium text-gray-900 mb-2">Error</h3>
5178
<p className="text-gray-600 mb-4">{error}</p>
52-
<button
53-
onClick={refetch}
54-
className="bg-cerulean-blue-500 text-white px-4 py-2 rounded-md hover:bg-cerulean-blue-600 focus:outline-none focus:ring-2 focus:ring-cerulean-blue-500 focus:ring-offset-2"
55-
>
56-
Try Again
57-
</button>
79+
<p className="text-gray-600 mb-4">Server URL: {serverUrl}</p>
80+
<div className="flex flex-col space-y-2 items-center">
81+
<button
82+
onClick={refetch}
83+
className="bg-cerulean-blue-500 text-white px-4 py-2 rounded-md hover:bg-cerulean-blue-600 focus:outline-none focus:ring-2 focus:ring-cerulean-blue-500 focus:ring-offset-2"
84+
>
85+
Try Again
86+
</button>
87+
<button
88+
onClick={handleResetServerSettings}
89+
className="text-red-600 px-4 py-2 rounded-md hover:text-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 border border-red-200"
90+
>
91+
Reset Server Settings
92+
</button>
93+
</div>
5894
</div>
5995
);
6096
}
@@ -64,7 +100,7 @@ export default function PageLayout({ children, maxWidth = "max-w-4xl", title, su
64100

65101
return (
66102
<>
67-
<div className={`${maxWidth} mx-auto px-4 sm:px-6 lg:px-8 mt-12`}>
103+
<div className={`${maxWidth} mx-auto px-4 md:px-8 mt-6 md:mt-12`}>
68104
<div className="relative mt-4">
69105
<div className="absolute w-full h-full bg-cerulean-blue-500 rounded-lg -top-1" />
70106
<div className="relative bg-white shadow-lg rounded-lg">

app/components/verification/BytecodeDiffModal.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,12 @@ export default function BytecodeDiffModal({
245245
}
246246

247247
// Try to use Web Worker for better performance
248-
if (typeof Worker !== 'undefined') {
248+
if (typeof Worker !== "undefined") {
249249
const result = await new Promise<BytecodeDiffResult>((resolve, reject) => {
250-
const worker = new Worker('/diffWorker.js');
250+
const worker = new Worker("/diffWorker.js");
251251
workerRef.current = worker;
252252
const id = Math.random().toString(36);
253-
253+
254254
worker.onmessage = (e) => {
255255
const { result, error, id: responseId } = e.data;
256256
if (responseId === id) {
@@ -263,21 +263,21 @@ export default function BytecodeDiffModal({
263263
}
264264
}
265265
};
266-
266+
267267
worker.onerror = (error) => {
268268
worker.terminate();
269269
workerRef.current = null;
270270
reject(error);
271271
};
272-
272+
273273
worker.postMessage({
274274
onchain: onchainBytecode,
275275
recompiled: recompiledBytecode,
276276
diffMode,
277-
id
277+
id,
278278
});
279279
});
280-
280+
281281
setDiffResult(result);
282282
} else {
283283
// Fallback to main thread with setTimeout
@@ -286,18 +286,18 @@ export default function BytecodeDiffModal({
286286
resolve(compareBytecodeDiff(onchainBytecode, recompiledBytecode, diffMode));
287287
}, 0);
288288
});
289-
289+
290290
setDiffResult(result);
291291
}
292292
} catch (error) {
293-
console.warn('Worker failed, falling back to main thread:', error);
293+
console.warn("Worker failed, falling back to main thread:", error);
294294
// Fallback to main thread calculation
295295
const result = await new Promise<BytecodeDiffResult>((resolve) => {
296296
setTimeout(() => {
297297
resolve(compareBytecodeDiff(onchainBytecode, recompiledBytecode, diffMode));
298298
}, 0);
299299
});
300-
300+
301301
setDiffResult(result);
302302
} finally {
303303
setIsCalculating(false);
@@ -374,7 +374,7 @@ export default function BytecodeDiffModal({
374374
<DialogTitle className="text-lg font-bold text-gray-900">{title} Bytecode Diff</DialogTitle>
375375
<button
376376
onClick={onClose}
377-
className="text-gray-400 hover:text-gray-600 p-1 focus:outline-none focus:ring-2 focus:ring-cerulean-blue-500 rounded hover:cursor-pointer transition-colors duration-200 ease-in-out"
377+
className="text-gray-400 hover:text-gray-600 p-1 focus:outline-none focus:ring-2 focus:ring-cerulean-blue-500 rounded transition-colors duration-200 ease-in-out"
378378
>
379379
<IoClose className="w-6 h-6 transition-transform duration-200 ease-in-out hover:scale-110" />
380380
</button>
@@ -438,7 +438,7 @@ export default function BytecodeDiffModal({
438438
onClick={() => handleDiffModeChange("chars")}
439439
disabled={isCalculating}
440440
className={`px-3 py-1 text-xs font-medium rounded transition-colors ${
441-
isCalculating ? "cursor-not-allowed opacity-50" : "cursor-pointer"
441+
isCalculating ? "cursor-not-allowed opacity-50" : ""
442442
} ${
443443
diffMode === "chars"
444444
? "bg-white text-gray-900 shadow-sm"
@@ -451,7 +451,7 @@ export default function BytecodeDiffModal({
451451
onClick={() => handleDiffModeChange("bytes")}
452452
disabled={isCalculating}
453453
className={`px-3 py-1 text-xs font-medium rounded transition-colors ${
454-
isCalculating ? "cursor-not-allowed opacity-50" : "cursor-pointer"
454+
isCalculating ? "cursor-not-allowed opacity-50" : ""
455455
} ${
456456
diffMode === "bytes"
457457
? "bg-white text-gray-900 shadow-sm"
@@ -467,7 +467,7 @@ export default function BytecodeDiffModal({
467467
<div className="flex bg-gray-100 rounded-lg p-1">
468468
<button
469469
onClick={() => handleViewModeChange("split")}
470-
className={`px-3 py-1 text-xs font-medium rounded transition-colors cursor-pointer ${
470+
className={`px-3 py-1 text-xs font-medium rounded transition-colors ${
471471
viewMode === "split"
472472
? "bg-white text-gray-900 shadow-sm"
473473
: "text-gray-600 hover:text-gray-900 hover:bg-gray-50"
@@ -477,7 +477,7 @@ export default function BytecodeDiffModal({
477477
</button>
478478
<button
479479
onClick={() => handleViewModeChange("unified")}
480-
className={`px-3 py-1 text-xs font-medium rounded transition-colors cursor-pointer ${
480+
className={`px-3 py-1 text-xs font-medium rounded transition-colors ${
481481
viewMode === "unified"
482482
? "bg-white text-gray-900 shadow-sm"
483483
: "text-gray-600 hover:text-gray-900 hover:bg-gray-50"
@@ -497,7 +497,7 @@ export default function BytecodeDiffModal({
497497
<div className="flex flex-col items-center justify-center space-y-4">
498498
<div className="animate-spin h-8 w-8 border-4 border-cerulean-blue-600 border-t-transparent rounded-full"></div>
499499
<div className="text-gray-600">Calculating diff...</div>
500-
<div className="text-sm text-gray-500">This may take a moment for large bytecode</div>
500+
<div className="text-sm text-gray-500">This may take a moment for big differences</div>
501501
</div>
502502
</div>
503503
) : diffResult ? (
@@ -535,7 +535,7 @@ export default function BytecodeDiffModal({
535535
<div className="mt-6 flex justify-end">
536536
<button
537537
onClick={onClose}
538-
className="inline-flex items-center px-4 py-2 rounded-md text-sm font-medium text-white bg-gray-500 hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-all duration-200 ease-in-out hover:cursor-pointer hover:scale-105"
538+
className="inline-flex items-center px-4 py-2 rounded-md text-sm font-medium text-white bg-gray-500 hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-all duration-200 ease-in-out hover:scale-105"
539539
>
540540
Close
541541
</button>

app/components/verification/ChainAndAddress.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default function ChainAndAddress({
150150
href={getRepoLink(currentChainContract.chainId, currentChainContract.address)}
151151
target="_blank"
152152
rel="noopener noreferrer"
153-
className="ml-2 text-sm text-green-600 hover:text-green-800 font-medium underline hover:cursor-pointer"
153+
className="ml-2 text-sm text-green-600 hover:text-green-800 font-medium underline"
154154
>
155155
<IoOpenOutline className="w-4 h-4 inline mr-0.5 mb-0.5" />
156156
View Contract
@@ -181,15 +181,15 @@ export default function ChainAndAddress({
181181
<button
182182
type="button"
183183
onClick={() => setIsModalOpen(true)}
184-
className="text-sm text-blue-600 hover:text-blue-800 font-medium underline hover:cursor-pointer"
184+
className="text-sm text-blue-600 hover:text-blue-800 font-medium underline"
185185
>
186186
See all
187187
</button>
188188
</p>
189189
</div>
190190
</div>
191191
) : (
192-
contractAddress && (
192+
isAddress(contractAddress) && (
193193
<p className="mt-1 text-sm text-gray-500">
194194
{shortenAddress(contractAddress)} not verified yet on any other chain
195195
</p>

0 commit comments

Comments
 (0)