Skip to content

Commit fc404cf

Browse files
Merge pull request #6 from verifier-alliance/replace-docs-page-with-embedded-readme
Replace transformations and artifacts pages with github embedded readme
2 parents 0d2f450 + 146d865 commit fc404cf

8 files changed

Lines changed: 93 additions & 276 deletions

docs/2. database-schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Verifier Alliance's database schema is in PostgreSQL and is intended to be a standard for storing and accessing verified smart contract data.
44

5-
In essence every smart contract verification (`verified_contracts` table) is a mapping between a compilation (`compiled_contracts`) and a deployment (`contract_deployments`). In addition `verified_contracts` defines "transformations". These are changes need to be made on the **recompiled bytecode** to reach the **onchain bytecode**. Transformations can be replacements of non-executional parts of the bytecode (e.g. immutables, libraries, metadata) or insertions at the end such as constructor arguments. Read more about them in the [transformations docs](/docs/transformations).
5+
In essence every smart contract verification (`verified_contracts` table) is a mapping between a compilation (`compiled_contracts`) and a deployment (`contract_deployments`). In addition `verified_contracts` defines "transformations". These are changes need to be made on the **recompiled bytecode** to reach the **onchain bytecode**. Transformations can be replacements of non-executional parts of the bytecode (e.g. immutables, libraries, metadata) or insertions at the end such as constructor arguments. Read more about them in the [Transformations and Artifacts docs](/docs/transformations-artifacts).
66

77
For deduplicating the source files and the bytecode across verifications the schema also includes a `code` and `sources` table with hashes.
88

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Transformations and Artifacts
3+
id: transformations-artifacts
4+
---
5+
6+
Transformations and artifacts are outputs of smart‑contract compilation and verification. Compilation artifacts include interface objects such as the ABI and detailed compiler data like the storage layout. Transformations come from verification; applying them to compiled bytecode yields the onchain bytecode. The next section explains and defines the structure of transformations and artifacts.
7+
8+
import EmbedReadmeTransformations from "./EmbedReadmeTransformations";
9+
10+
<EmbedReadmeTransformations />

docs/3. transformations.md

Lines changed: 0 additions & 183 deletions
This file was deleted.

docs/4. artifacts.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

docs/EmbedReadme.jsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React, { useEffect, useState } from "react";
2+
import { parse } from "marked";
3+
4+
export default function EmbedReadme({ repo, branch, readmePath, rawBaseUrl, pageBaseUrl }) {
5+
const [content, setContent] = useState();
6+
7+
useEffect(() => {
8+
fetch(rawBaseUrl + "/" + repo + "/" + branch + readmePath)
9+
.then((response) => response.text())
10+
.then((text) => {
11+
// Replace relative markdown links with absolute ones
12+
// Matches markdown links that don't start with "http"
13+
const processedText = text.replace(/\[([^\]]+)\]\((?!http)([^)]+)\)/g, (match, title, path) => {
14+
// Handle anchor links
15+
if (path.startsWith("#")) {
16+
return `[${title}](${pageBaseUrl}/${repo}/tree/${branch}${readmePath}${path})`;
17+
}
18+
19+
// Resolve relative paths (including ../)
20+
const currentPath = readmePath.split("/").slice(0, -1);
21+
const pathParts = path.split("/");
22+
23+
let resolvedPath = [...currentPath];
24+
for (const part of pathParts) {
25+
if (part === "..") {
26+
resolvedPath.pop();
27+
} else {
28+
resolvedPath.push(part);
29+
}
30+
}
31+
32+
return `[${title}](${pageBaseUrl}/${repo}/tree/${branch}/${resolvedPath.join("/")})`;
33+
});
34+
setContent(parse(processedText));
35+
});
36+
}, []);
37+
38+
if (!content) return "Loading from " + rawBaseUrl + readmePath + "...";
39+
return (
40+
<div>
41+
<div>
42+
<i>
43+
Content from <a href={`${pageBaseUrl}/${repo}/tree/${branch}${readmePath}`}>{repo + readmePath}</a>
44+
</i>
45+
</div>
46+
<div dangerouslySetInnerHTML={{ __html: content }} />{" "}
47+
</div>
48+
);
49+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import EmbedReadme from "./EmbedReadme";
2+
import React from "react";
3+
const repo = "verifier-alliance/database-specs";
4+
const branch = "master";
5+
const readmePath = "/json-schemas/README.md";
6+
const rawBaseUrl = "https://raw.githubusercontent.com";
7+
const pageBaseUrl = "https://github.com";
8+
9+
export default function() {
10+
return (
11+
<EmbedReadme
12+
repo={repo}
13+
branch={branch}
14+
readmePath={readmePath}
15+
rawBaseUrl={rawBaseUrl}
16+
pageBaseUrl={pageBaseUrl}
17+
/>
18+
);
19+
}

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)