Skip to content

Commit

Permalink
Rewrite readme and contributing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor committed Oct 24, 2023
1 parent 87fffc8 commit 331c78a
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 95 deletions.
79 changes: 48 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,57 @@ We welcome all kinds of contributions :)

### Repository structure and package managers

The repository contains two packages, `ethereum-viewer` extension and the VSCode
compilation meant for hosting it online.
The repository contains few packages:

All packages (currently one) except of `@dethcrypto/ethereum-viewer-vscode-host`
located in `packages/vscode-host` are managed by `pnpm`. As VSCode depends on
Yarn, our `vscode-host` also needs Yarn.
- `ethereum-viewer` - VSCode extension, this is where most of the business logic
resides,
- `vscode-host` - tweaked VSCode instance. Default settings were changed and
some features hidden. Note: since some time, vscode officially supports web
builds which greatly simplified this package,
- `entrypoint`` - Simple website that cointains an iframe to vscode host. It's
done so multiple instances of DethCode for different chains, can share the
same settings (because they all use a single instance under the hood).

### Step by step instructions
All packages except of `@dethcrypto/vscode-host` located in
`packages/vscode-host` are managed by `pnpm`. As VSCode depends on Yarn, our
`vscode-host` also needs Yarn.

```sh
# You need to create dummy certs using mkcert - https://github.com/FiloSottile/mkcert
cd ./certs
mkcert localhost
mkcert -install
cd ..
## Development

# install deps
```
pnpm install
pnpm build # this builds whole vscode and can take A LOT of time. If you are having issues, read below
pnpm serve
```
cd packages/ethereum-viewer # build for the first time
pnpm build
cd packages/vscode-host
node scripts/prepareVSCode.js # clones vscode into ./vscode dir
node scripts/compileVSCode.js
node scripts/prepareAdditionalExtensions.js # extensions like solidity and vyper support
node scripts/copyExtensions.js
### Scripts
cd ./vscode
node ./scripts/code-web-deth.js # loads extensions from ./packages/vscode-host/dist/extensions
yarn watch # in a new tab
yarn watch-web # in a new tab
```

- **`pnpm install`** - Installs dependencies for the workspace,
`ethereum-viewer` extension, and triggers `yarn install` for `vscode-host`
through the `postinstall` script.
Changes to vscode will be automatically applied. To make them permanent copy
them to `./packages/vscode-host/src/`.

- **`pnpm build`** - Builds all packages.
After introducing changes to `packages/ethereum-viewer` run
`pnpm run build:dev`.

If you are having issues with MacOS and Python try the following:
```
$ brew install sqlite
$ npm config set sqlite /opt/homebrew/opt/sqlite
$ npm config set python python3
```
Btw. this will be improved soon ;)

- **`pnpm watch`** - Starts webpack for `ethereum-extension` in watch mode.
## Production build

- **`pnpm serve`** - Starts HTTP server with `vscode-host`.
Note: full, production build of VSCode host is painfully slow and takes ~0.5h
even on M1 Mac.

- **`pnpm dev`** - Copies `ethereum-extension` and serves `vscode-host`. Run
alongside `pnpm watch`.
```
pnpm build
```

### Resources

Expand All @@ -59,3 +66,13 @@ terms.
- https://code.visualstudio.com/api/extension-guides/web-extensions
- https://code.visualstudio.com/api/references/vscode-api#FileSystemProvider
- https://github.com/microsoft/vscode-extension-samples/blob/main/fsprovider-sample/README.md

### Troubleshooting

If you are having issues with MacOS and Python try the following:

```
$ brew install sqlite
$ npm config set sqlite /opt/homebrew/opt/sqlite
$ npm config set python python3
```
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
<h2 align="center">DethCode</h2>
<p align="center">
<a href="https://github.com/dethcrypto/ethereum-code-viewer/actions"><img alt="Build Status" src="https://github.com/dethcrypto/ethereum-code-viewer/actions/workflows/ci.yml/badge.svg"></a>
<a href="https://discord.gg/wQDkeDgzgv"><img alt="Join our Discord!" src="https://img.shields.io/discord/895381864922091630.svg?color=7289da&label=deth&logo=discord&style=flat-square"></a>
</p>
<p align="center"><strong>View source of deployed Ethereum smart contracts in VS Code</strong></p>
<p align="center">While on Etherscan, change <code>.io</code> to <code>.deth.net</code> and browse contracts comfortably in ephemeral VS Code instance</p>
<p align="center">
<em>💸 Enjoy using DethCode? Consider funding development via <a href="https://gitcoin.co/grants/4038/deth-typechain">GitCoin</a> 💸</em>
</p>
</p>

## Usage
Expand All @@ -38,7 +34,7 @@ javascript: location.href = location.href.replace(/\.\w+(\/)/, ".deth.net/")
supported chains][supported_explorers])

[supported_explorers]:
https://github.com/dethcrypto/ethereum-code-viewer/blob/main/docs/supported-explorers.md
https://github.com/dethcrypto/dethcode/blob/main/packages/ethereum-viewer/src/explorer/networks.ts#L38

## Motivation

Expand All @@ -52,8 +48,26 @@ DethCode was born out of frustration, and it's here to fix all of these issues.
In addition, it improves the experience by automatically following the
implementation of proxies and so on.

### Is it still relevant since Etherscan implements something similar?

Etherscan decided that they like the idea of browsing smart contracts in
ephemeral VSCode instance so much that they decided to make it part of the their
product. We don't hold a grudge against them and this is precisely why DethCode
needs to live on!

DethCode is a fully open-source, public good that is available for anyone. Other
blockchain explorers can use it/self-host it instead of developing the same
thing again.

Finally, we are preparing to launch, new advanced features that will make
DethCode unique product again.

## Examples

- Optimism L1CrossDomainMessenger:
[dethcode](https://etherscan.deth.net/address/0x25ace71c97b33cc4729cf772ae268934f7ab5fa1)
|
[etherscan](https://etherscan.io/address/0x25ace71c97b33cc4729cf772ae268934f7ab5fa1#code)
- Arbitrum ERC20 Gateway on mainnet:
[dethcode](https://etherscan.deth.net/address/0xa3a7b6f88361f48403514059f1f16c8e78d60eec)
|
Expand All @@ -62,28 +76,15 @@ implementation of proxies and so on.
[dethcode](https://arbiscan.deth.net/address/0x09e9222e96e7b4ae2a407b98d48e330053351eee)
|
[arbiscan](https://arbiscan.io/address/0x09e9222e96e7b4ae2a407b98d48e330053351eee#code)
- Optimism L1CrossDomainMessenger:
[dethcode](https://etherscan.deth.net/address/0x25ace71c97b33cc4729cf772ae268934f7ab5fa1)
|
[etherscan](https://etherscan.io/address/0x25ace71c97b33cc4729cf772ae268934f7ab5fa1#code)
- Dai Stablecoin:
[dethcode](https://etherscan.deth.net/address/0x6b175474e89094c44da98b954eedeac495271d0f)
|
[etherscan](https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#code)

## Contributing
## Contributing and development

Check out our [contributing guidelines](./CONTRIBUTING.md)
Check out our [contributing guide](./CONTRIBUTING.md).

## Social

Follow us on [Twitter](https://twitter.com/dethcrypto)!

## Development

```
cd packages/vscode-host/vscode
./scripts/code-web-deth.js # loads extensions from ./packages/vscode-host/dist/extensions
yarn watch
yarn watch-web
```
Follow me on [Twitter](https://twitter.com/krzkaczor).
23 changes: 0 additions & 23 deletions docs/supported-explorers.md

This file was deleted.

1 change: 1 addition & 0 deletions packages/ethereum-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"vscode:prepublish": "yarn run build:prod",
"build": "webpack",
"build:prod": "webpack --mode production --devtool hidden-source-map",
"build:dev": "pnpm build && mkdir -p ../vscode-host/dist/extensions/ethereum-viewer/dist && cp -Rf ./dist/ ../vscode-host/dist/extensions/ethereum-viewer/dist && cp -f ./package.json ../vscode-host/dist/extensions/ethereum-viewer/",
"watch": "webpack --watch",
"pretest": "yarn run build",
"lint": "eslint src --ext ts",
Expand Down
10 changes: 9 additions & 1 deletion packages/vscode-host/scripts/compileVSCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ function compileVSCode() {
// Use simple workbench
let copiedFilesReport = "Copied files: \n";
globSync("src/**/*.*", { dot: true }).forEach((file) => {
if (!file.endsWith('typescript.test.ts') && (file.endsWith(".test.ts") || file.includes("src/test/"))) return;
if (
!file.endsWith("typescript.test.ts") &&
(file.endsWith(".test.ts") || file.includes("src/test/"))
)
return;

const destination = file.replace("src/", "vscode/");
copySync(file, destination);
Expand Down Expand Up @@ -53,6 +57,10 @@ function compileVSCode() {
);
});

if (process.env.SKIP_COMPILE === "1") {
return;
}

log.info("============ Compiling VSCode...");
chdir("vscode");
execSync("yarn gulp vscode-web-min", { stdio: "inherit" });
Expand Down
15 changes: 0 additions & 15 deletions packages/vscode-host/scripts/copyExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ function copyExtensions() {

chdir(__dirname, "../vscode");

const extensions = [
// main built-in extension, responsible for fetching and displaying contracts
{
extensionPath: "ethereum-viewer",
packageJSON: require("../../ethereum-viewer/package.json"),
packageNLS: null,
},
// additional built-in extensions, Solidity and Vyper language support
...additionalExtensions.map((ext) => ({
extensionPath: ext.name,
packageJSON: ext.getPackageJSON(),
packageNLS: null,
})),
];

// copy our additional built-in extensions
log.info("Copying ethereum-viewer extension...");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ export class GettingStartedPage extends EditorPane {
$(
"a",
{
href: "https://etherscan.deth.net/address/0xa3a7b6f88361f48403514059f1f16c8e78d60eec",
href: "https://etherscan.deth.net/address/0x25ace71c97b33cc4729cf772ae268934f7ab5fa1",
},
"Arbitrum ERC20 Gateway"
"Optimism's L1CrossDomainMessenger"
)
),
$(
Expand All @@ -813,9 +813,9 @@ export class GettingStartedPage extends EditorPane {
$(
"a",
{
href: "https://etherscan.deth.net/address/0x25ace71c97b33cc4729cf772ae268934f7ab5fa1",
href: "https://etherscan.deth.net/address/0xa3a7b6f88361f48403514059f1f16c8e78d60eec",
},
"L1CrossDomainMessenger"
"Arbitrum ERC20 Gateway"
)
),
$(
Expand Down

0 comments on commit 331c78a

Please sign in to comment.