Skip to content

Commit

Permalink
feat: simplified config (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Nov 21, 2024
1 parent c035e90 commit fd21158
Show file tree
Hide file tree
Showing 23 changed files with 1,819 additions and 797 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
}
55 changes: 28 additions & 27 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"ignore": ["out/"],
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"performance": {
"noDelete": "off"
},
"style": {
"useTemplate": "off"
}
}
},
"formatter": {
"enabled": true,
"formatWithErrors": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 120,
"ignore": []
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"ignore": ["out/"],
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"performance": {
"noDelete": "off"
},
"style": {
"useTemplate": "off",
"noNonNullAssertion": "off"
}
}
},
"formatter": {
"enabled": true,
"formatWithErrors": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120,
"ignore": []
}
}
Binary file modified bun.lockb
Binary file not shown.
83 changes: 42 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
{
"name": "catapulta-verify",
"version": "1.1.1",
"author": "@kartojal <david@web3ops.co> (https://catapulta.sh/)",
"repository": {
"type": "git",
"url": "git+https://github.com/catapulta-sh/catapulta-verify.git"
},
"main": "./out/index.mjs",
"private": false,
"publishConfig": {
"access": "public"
},
"files": [
"out/index.mjs"
],
"devDependencies": {
"@biomejs/biome": "1.4.1",
"@types/chalk": "^2.2.0",
"bun-types": "latest",
"chalk": "^5.3.0",
"dotenv": "^16.3.1",
"ts-command-line-args": "^2.5.1"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"bin": {
"catapulta-verify": "out/index.mjs"
},
"bugs": {
"url": "https://github.com/catapulta-sh/catapulta-verify/issues",
"email": "david@web3ops.co"
},
"homepage": "https://github.com/catapulta-sh/catapulta-verify#readme",
"license": "MIT",
"scripts": {
"build": "bun build ./src/index.ts --outfile=out/index.mjs --target node",
"postbuild": "bunx rexreplace '^(#!.+\\n)?' '$1import { createRequire as createImportMetaRequire } from \"module\"; import.meta.require ||= (id) => createImportMetaRequire(import.meta.url)(id);\\n' -GM out/index.mjs",
"lint:fix": "bunx @biomejs/biome check . --apply",
"lint": "bunx @biomejs/biome check ."
}
"name": "catapulta-verify",
"version": "1.1.1",
"author": "@kartojal <david@web3ops.co> (https://catapulta.sh/)",
"repository": {
"type": "git",
"url": "git+https://github.com/catapulta-sh/catapulta-verify.git"
},
"main": "./out/index.mjs",
"private": false,
"publishConfig": {
"access": "public"
},
"files": ["out/index.mjs"],
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/chalk": "^2.2.0",
"bun-types": "1.1.36",
"chalk": "^5.3.0",
"dotenv": "^16.4.5",
"ts-command-line-args": "^2.5.1",
"typescript": "^5.6.3",
"vitest": "^2.1.5"
},
"bin": {
"catapulta-verify": "out/index.mjs"
},
"bugs": {
"url": "https://github.com/catapulta-sh/catapulta-verify/issues",
"email": "david@web3ops.co"
},
"homepage": "https://github.com/catapulta-sh/catapulta-verify#readme",
"license": "MIT",
"scripts": {
"build": "bun build ./src/index.ts --outfile=out/index.mjs --target node",
"postbuild": "bunx rexreplace '^(#!.+\\n)?' '$1import { createRequire as createImportMetaRequire } from \"module\"; import.meta.require ||= (id) => createImportMetaRequire(import.meta.url)(id);\\n' -GM out/index.mjs",
"lint:fix": "bunx @biomejs/biome check . --write",
"lint": "bunx @biomejs/biome check .",
"test": "vitest"
},
"dependencies": {
"@bgd-labs/rpc-env": "^2.0.1"
}
}
40 changes: 40 additions & 0 deletions prepare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { writeFileSync } from "node:fs";

type RouteScanResponse = {
items: {
workspace: string;
chainId: string;
}[];
};

async function getRoutescan() {
const result = await fetch("https://cdn-canary.routescan.io/api/evm/all/explorers");
const data = (await result.json()) as RouteScanResponse;
const formatted = data.items.map((d) => ({
api: `https://api.routescan.io/v2/network/${d.workspace}/evm/${d.chainId}/etherscan`,
explorer: `${d.chainId}.routescan.io`,
chainId: Number(d.chainId),
}));
writeFileSync("src/explorers/routescan.json", JSON.stringify(formatted, null, 2));
}

type EtherscanResponse = {
result: {
blockexplorer: string;
chainid: string;
apiurl: string;
}[];
};
async function getEtherscan() {
const result = await fetch("https://api.etherscan.io/v2/chainlist");
const data = (await result.json()) as EtherscanResponse;
const formatted = data.result.map((d) => ({
api: d.apiurl,
explorer: d.blockexplorer,
chainId: Number(d.chainid),
}));
writeFileSync("src/explorers/etherscan.json", JSON.stringify(formatted, null, 2));
}

getRoutescan();
getEtherscan();
82 changes: 41 additions & 41 deletions src/cli-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@ import { parse } from "ts-command-line-args";
import type { InputParams } from "./types";

export const args = parse<InputParams>(
{
broadcastPath: {
type: String,
alias: "b",
description:
"Path of the broadcast report json file to analyze the txs in search of smart contracts deployments.",
},
help: {
type: Boolean,
optional: true,
alias: "h",
description: "Prints this usage guide",
},
rpcUrl: {
type: String,
optional: true,
alias: "r",
description:
"RPC URL to fetch transaction details, mandatory to support for debug_traceTransaction. You can use Alchemy or Quicknode providers if available.",
},
explorerUrl: {
type: String,
optional: true,
alias: "e",
description: "Etherscan API endpoint",
},
etherscanApiKey: {
type: String,
optional: true,
alias: "k",
description: "Etherscan API key",
},
{
broadcastPath: {
type: String,
alias: "b",
description:
"Path of the broadcast report json file to analyze the txs in search of smart contracts deployments.",
},
{
helpArg: "help",
headerContentSections: [
{
header: "catapulta-verify",
content:
'Verify smart contracts at Etherscan using Forge broadcast reports and debug_traceTransaction. This is the "lite" open source version of Catapulta.sh, a zero config deployment tool for Foundry scripts.\n\nUsage:\n\n npx catapulta-verify -b broadcast/Script.sol/11155111/run-latest.json --etherscan-url <URL> --etherscan-api-key <API_KEY> \n\nDocumentation\n\nCheck out https://github.com/catapulta-sh/verify repository to see the full documentation.\n\nCatapulta, plug-n-play deployment platform\n\nIf you want to remove all boilerplate configs like RPC Urls, Etherscan API keys, be able to automatize all verifications without long commands at deployment time, check out https://catapulta.sh website to discover the full version of Catapulta.',
},
],
help: {
type: Boolean,
optional: true,
alias: "h",
description: "Prints this usage guide",
},
rpcUrl: {
type: String,
optional: true,
alias: "r",
description:
"RPC URL to fetch transaction details, mandatory to support for debug_traceTransaction. You can use Alchemy or Quicknode providers if available.",
},
explorerUrl: {
type: String,
optional: true,
alias: "e",
description: "Etherscan API endpoint",
},
etherscanApiKey: {
type: String,
optional: true,
alias: "k",
description: "Etherscan API key",
},
},
{
helpArg: "help",
headerContentSections: [
{
header: "catapulta-verify",
content:
'Verify smart contracts at Etherscan using Forge broadcast reports and debug_traceTransaction. This is the "lite" open source version of Catapulta.sh, a zero config deployment tool for Foundry scripts.\n\nUsage:\n\n npx catapulta-verify -b broadcast/Script.sol/11155111/run-latest.json --etherscan-url <URL> --etherscan-api-key <API_KEY> \n\nDocumentation\n\nCheck out https://github.com/catapulta-sh/verify repository to see the full documentation.\n\nCatapulta, plug-n-play deployment platform\n\nIf you want to remove all boilerplate configs like RPC Urls, Etherscan API keys, be able to automatize all verifications without long commands at deployment time, check out https://catapulta.sh website to discover the full version of Catapulta.',
},
],
},
);
Loading

0 comments on commit fd21158

Please sign in to comment.