create-ponder 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +1,40 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
3
+ /* eslint-disable @typescript-eslint/no-var-requires */
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
6
  };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
19
- mod
20
- ));
21
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
- var create_ponder_exports = {};
23
- module.exports = __toCommonJS(create_ponder_exports);
24
- var import_cac = require("cac");
25
- var import_node_path = __toESM(require("node:path"));
26
- var import_package = __toESM(require("../../package.json"));
27
- const cli = (0, import_cac.cac)(import_package.default.name).version(import_package.default.version).usage("[options]").help().option("--dir [path]", "Path to directory for generated project").option("--from-subgraph [path]", "Path to subgraph directory").option("--from-etherscan [url]", "Link to etherscan contract page").option("--etherscan-api-key [key]", "Etherscan API key");
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const cac_1 = require("cac");
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
+ // @ts-ignore
12
+ const package_json_1 = __importDefault(require("../../../package.json"));
13
+ const cli = (0, cac_1.cac)(package_json_1.default.name)
14
+ .version(package_json_1.default.version)
15
+ .usage("[options]")
16
+ .help()
17
+ .option("--dir [path]", "Path to directory for generated project")
18
+ .option("--from-subgraph [path]", "Path to subgraph directory")
19
+ .option("--from-etherscan [url]", "Link to etherscan contract page")
20
+ .option("--etherscan-api-key [key]", "Etherscan API key");
28
21
  const parsed = cli.parse(process.argv);
29
22
  const options = parsed.options;
30
23
  if (options.help) {
31
- process.exit(0);
24
+ process.exit(0);
32
25
  }
26
+ // Validate CLI options.
33
27
  if (options.fromSubgraph && options.fromEtherscan) {
34
- throw new Error(`Cannot specify more than one "--from" option:
28
+ throw new Error(`Cannot specify more than one "--from" option:
35
29
  --from-subgraph
36
30
  --from-etherscan
37
31
  `);
38
32
  }
39
33
  const validatedOptions = {
40
- ponderRootDir: import_node_path.default.resolve(".", options.dir ? options.dir : "ponder"),
41
- fromSubgraph: options.fromSubgraph,
42
- fromEtherscan: options.fromEtherscan,
43
- etherscanApiKey: options.etherscanApiKey
34
+ // Default `dir` to "ponder".
35
+ ponderRootDir: node_path_1.default.resolve(".", options.dir ? options.dir : "ponder"),
36
+ fromSubgraph: options.fromSubgraph,
37
+ fromEtherscan: options.fromEtherscan,
38
+ etherscanApiKey: options.etherscanApiKey,
44
39
  };
45
40
  require("../index").run(validatedOptions);
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ export interface CreatePonderOptions {
3
+ ponderRootDir: string;
4
+ fromSubgraph?: string;
5
+ fromEtherscan?: string;
6
+ etherscanApiKey?: string;
7
+ }
@@ -0,0 +1,5 @@
1
+ export declare type PM = "npm" | "yarn" | "pnpm";
2
+ declare const detect: ({ cwd }?: {
3
+ cwd?: string | undefined;
4
+ }) => Promise<PM>;
5
+ export { detect };
@@ -1,109 +1,78 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
4
  };
12
- var __copyProps = (to, from, except, desc) => {
13
- if ((from && typeof from === "object") || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, {
17
- get: () => from[key],
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
19
- });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (
24
- (target = mod != null ? __create(__getProtoOf(mod)) : {}),
25
- __copyProps(
26
- isNodeMode || !mod || !mod.__esModule
27
- ? __defProp(target, "default", { value: mod, enumerable: true })
28
- : target,
29
- mod
30
- )
31
- );
32
- var __toCommonJS = (mod) =>
33
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
- var detectPackageManager_exports = {};
35
- __export(detectPackageManager_exports, {
36
- detect: () => detect,
37
- });
38
- module.exports = __toCommonJS(detectPackageManager_exports);
39
- var import_execa = __toESM(require("execa"));
40
- var import_fs = require("fs");
41
- var import_path = require("path");
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.detect = void 0;
7
+ // Adapted from https://github.com/egoist/detect-package-manager
8
+ const execa_1 = __importDefault(require("execa"));
9
+ const fs_1 = require("fs");
10
+ const path_1 = require("path");
42
11
  async function pathExists(p) {
43
- try {
44
- await import_fs.promises.access(p);
45
- return true;
46
- } catch {
47
- return false;
48
- }
12
+ try {
13
+ await fs_1.promises.access(p);
14
+ return true;
15
+ }
16
+ catch {
17
+ return false;
18
+ }
49
19
  }
50
- const cache = /* @__PURE__ */ new Map();
20
+ const cache = new Map();
51
21
  function hasGlobalInstallation(pm) {
52
- const key = `has_global_${pm}`;
53
- if (cache.has(key)) {
54
- return Promise.resolve(cache.get(key));
55
- }
56
- return (0, import_execa.default)(pm, ["--version"])
57
- .then((res) => {
58
- return /^\d+.\d+.\d+$/.test(res.stdout);
22
+ const key = `has_global_${pm}`;
23
+ if (cache.has(key)) {
24
+ return Promise.resolve(cache.get(key));
25
+ }
26
+ return (0, execa_1.default)(pm, ["--version"])
27
+ .then((res) => {
28
+ return /^\d+.\d+.\d+$/.test(res.stdout);
59
29
  })
60
- .then((value) => {
61
- cache.set(key, value);
62
- return value;
30
+ .then((value) => {
31
+ cache.set(key, value);
32
+ return value;
63
33
  })
64
- .catch(() => false);
34
+ .catch(() => false);
65
35
  }
66
36
  function getTypeofLockFile(cwd = ".") {
67
- const key = `lockfile_${cwd}`;
68
- if (cache.has(key)) {
69
- return Promise.resolve(cache.get(key));
70
- }
71
- return Promise.all([
72
- pathExists((0, import_path.resolve)(cwd, "yarn.lock")),
73
- pathExists((0, import_path.resolve)(cwd, "package-lock.json")),
74
- pathExists((0, import_path.resolve)(cwd, "pnpm-lock.yaml")),
75
- ]).then(([isYarn, isNpm, isPnpm]) => {
76
- let value = null;
77
- if (isYarn) {
78
- value = "yarn";
79
- } else if (isPnpm) {
80
- value = "pnpm";
81
- } else if (isNpm) {
82
- value = "npm";
37
+ const key = `lockfile_${cwd}`;
38
+ if (cache.has(key)) {
39
+ return Promise.resolve(cache.get(key));
83
40
  }
84
- cache.set(key, value);
85
- return value;
86
- });
41
+ return Promise.all([
42
+ pathExists((0, path_1.resolve)(cwd, "yarn.lock")),
43
+ pathExists((0, path_1.resolve)(cwd, "package-lock.json")),
44
+ pathExists((0, path_1.resolve)(cwd, "pnpm-lock.yaml")),
45
+ ]).then(([isYarn, isNpm, isPnpm]) => {
46
+ let value = null;
47
+ if (isYarn) {
48
+ value = "yarn";
49
+ }
50
+ else if (isPnpm) {
51
+ value = "pnpm";
52
+ }
53
+ else if (isNpm) {
54
+ value = "npm";
55
+ }
56
+ cache.set(key, value);
57
+ return value;
58
+ });
87
59
  }
88
60
  const detect = async ({ cwd } = {}) => {
89
- const type = await getTypeofLockFile(cwd);
90
- if (type) {
91
- return type;
92
- }
93
- const [hasYarn, hasPnpm] = await Promise.all([
94
- hasGlobalInstallation("yarn"),
95
- hasGlobalInstallation("pnpm"),
96
- ]);
97
- if (hasPnpm) {
98
- return "pnpm";
99
- }
100
- if (hasYarn) {
101
- return "yarn";
102
- }
103
- return "npm";
61
+ const type = await getTypeofLockFile(cwd);
62
+ if (type) {
63
+ return type;
64
+ }
65
+ const [hasYarn, hasPnpm] = await Promise.all([
66
+ hasGlobalInstallation("yarn"),
67
+ hasGlobalInstallation("pnpm"),
68
+ ]);
69
+ // Prefer pnpm, yarn, then npm
70
+ if (hasPnpm) {
71
+ return "pnpm";
72
+ }
73
+ if (hasYarn) {
74
+ return "yarn";
75
+ }
76
+ return "npm";
104
77
  };
105
- // Annotate the CommonJS export names for ESM import in node:
106
- 0 &&
107
- (module.exports = {
108
- detect,
109
- });
78
+ exports.detect = detect;
@@ -0,0 +1,4 @@
1
+ export declare const getNetworkByEtherscanHostname: (hostname: string) => {
2
+ name: string;
3
+ chainId: number;
4
+ } | undefined;
@@ -1,51 +1,23 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var getEtherscanChainId_exports = {};
24
- __export(getEtherscanChainId_exports, {
25
- getNetworkByEtherscanHostname: () => getNetworkByEtherscanHostname,
26
- });
27
- module.exports = __toCommonJS(getEtherscanChainId_exports);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNetworkByEtherscanHostname = void 0;
28
4
  const networkByEtherscanHostname = {
29
- "etherscan.io": { name: "mainnet", chainId: 1 },
30
- "ropsten.etherscan.io": { name: "ropsten", chainId: 3 },
31
- "rinkeby.etherscan.io": { name: "rinkeby", chainId: 4 },
32
- "goerli.etherscan.io": { name: "goerli", chainId: 5 },
33
- "kovan.etherscan.io": { name: "kovan", chainId: 42 },
34
- "sepolia.etherscan.io": { name: "sepolia", chainId: 11155111 },
35
- "optimistic.etherscan.io": { name: "optimism", chainId: 10 },
36
- "kovan-optimistic.etherscan.io": { name: "optimism-kovan", chainId: 69 },
37
- "goerli-optimism.etherscan.io": { name: "optimism-goerli", chainId: 420 },
38
- "polygonscan.com": { name: "polygon", chainId: 137 },
39
- "mumbai.polygonscan.com": { name: "polygon-mumbai", chainId: 80001 },
40
- "arbiscan.io": { name: "arbitrum", chainId: 42161 },
41
- "testnet.arbiscan.io": { name: "arbitrum-rinkeby", chainId: 421611 },
42
- "goerli.arbiscan.io": { name: "arbitrum-goerli", chainId: 421613 },
5
+ "etherscan.io": { name: "mainnet", chainId: 1 },
6
+ "ropsten.etherscan.io": { name: "ropsten", chainId: 3 },
7
+ "rinkeby.etherscan.io": { name: "rinkeby", chainId: 4 },
8
+ "goerli.etherscan.io": { name: "goerli", chainId: 5 },
9
+ "kovan.etherscan.io": { name: "kovan", chainId: 42 },
10
+ "sepolia.etherscan.io": { name: "sepolia", chainId: 11155111 },
11
+ "optimistic.etherscan.io": { name: "optimism", chainId: 10 },
12
+ "kovan-optimistic.etherscan.io": { name: "optimism-kovan", chainId: 69 },
13
+ "goerli-optimism.etherscan.io": { name: "optimism-goerli", chainId: 420 },
14
+ "polygonscan.com": { name: "polygon", chainId: 137 },
15
+ "mumbai.polygonscan.com": { name: "polygon-mumbai", chainId: 80001 },
16
+ "arbiscan.io": { name: "arbitrum", chainId: 42161 },
17
+ "testnet.arbiscan.io": { name: "arbitrum-rinkeby", chainId: 421611 },
18
+ "goerli.arbiscan.io": { name: "arbitrum-goerli", chainId: 421613 },
43
19
  };
44
20
  const getNetworkByEtherscanHostname = (hostname) => {
45
- return networkByEtherscanHostname[hostname];
21
+ return networkByEtherscanHostname[hostname];
46
22
  };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 &&
49
- (module.exports = {
50
- getNetworkByEtherscanHostname,
51
- });
23
+ exports.getNetworkByEtherscanHostname = getNetworkByEtherscanHostname;
@@ -0,0 +1,2 @@
1
+ export declare const getGraphProtocolChainId: (networkName: string) => number | undefined;
2
+ export declare const subgraphYamlFileNames: string[];
@@ -1,71 +1,41 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var getGraphProtocolChainId_exports = {};
24
- __export(getGraphProtocolChainId_exports, {
25
- getGraphProtocolChainId: () => getGraphProtocolChainId,
26
- subgraphYamlFileNames: () => subgraphYamlFileNames,
27
- });
28
- module.exports = __toCommonJS(getGraphProtocolChainId_exports);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subgraphYamlFileNames = exports.getGraphProtocolChainId = void 0;
4
+ // https://github.com/graphprotocol/graph-cli/blob/main/src/protocols/index.js#L40
5
+ // https://chainlist.org/
29
6
  const chainIdByGraphNetwork = {
30
- mainnet: 1,
31
- kovan: 42,
32
- rinkeby: 4,
33
- ropsten: 3,
34
- goerli: 5,
35
- "poa-core": 99,
36
- "poa-sokol": 77,
37
- xdai: 100,
38
- matic: 137,
39
- mumbai: 80001,
40
- fantom: 250,
41
- "fantom-testnet": 4002,
42
- bsc: 56,
43
- chapel: -1,
44
- clover: 0,
45
- avalanche: 43114,
46
- fuji: 43113,
47
- celo: 42220,
48
- "celo-alfajores": 44787,
49
- fuse: 122,
50
- moonbeam: 1284,
51
- moonriver: 1285,
52
- mbase: -1,
53
- "arbitrum-one": 42161,
54
- "arbitrum-rinkeby": 421611,
55
- optimism: 10,
56
- "optimism-kovan": 69,
57
- aurora: 1313161554,
58
- "aurora-testnet": 1313161555,
7
+ mainnet: 1,
8
+ kovan: 42,
9
+ rinkeby: 4,
10
+ ropsten: 3,
11
+ goerli: 5,
12
+ "poa-core": 99,
13
+ "poa-sokol": 77,
14
+ xdai: 100,
15
+ matic: 137,
16
+ mumbai: 80001,
17
+ fantom: 250,
18
+ "fantom-testnet": 4002,
19
+ bsc: 56,
20
+ chapel: -1,
21
+ clover: 0,
22
+ avalanche: 43114,
23
+ fuji: 43113,
24
+ celo: 42220,
25
+ "celo-alfajores": 44787,
26
+ fuse: 122,
27
+ moonbeam: 1284,
28
+ moonriver: 1285,
29
+ mbase: -1,
30
+ "arbitrum-one": 42161,
31
+ "arbitrum-rinkeby": 421611,
32
+ optimism: 10,
33
+ "optimism-kovan": 69,
34
+ aurora: 1313161554,
35
+ "aurora-testnet": 1313161555,
59
36
  };
60
37
  const getGraphProtocolChainId = (networkName) => {
61
- return chainIdByGraphNetwork[networkName];
38
+ return chainIdByGraphNetwork[networkName];
62
39
  };
63
- const subgraphYamlFileNames = ["subgraph.yaml"].concat(
64
- Object.keys(chainIdByGraphNetwork).map((n) => `subgraph-${n}.yaml`)
65
- );
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 &&
68
- (module.exports = {
69
- getGraphProtocolChainId,
70
- subgraphYamlFileNames,
71
- });
40
+ exports.getGraphProtocolChainId = getGraphProtocolChainId;
41
+ exports.subgraphYamlFileNames = ["subgraph.yaml"].concat(Object.keys(chainIdByGraphNetwork).map((n) => `subgraph-${n}.yaml`));
@@ -0,0 +1,27 @@
1
+ export declare type GraphSource = {
2
+ kind: string;
3
+ name: string;
4
+ network: string;
5
+ source: {
6
+ address: string;
7
+ abi: string;
8
+ startBlock?: number;
9
+ };
10
+ mapping: {
11
+ kind: string;
12
+ apiVersion: string;
13
+ language: string;
14
+ entities: string[];
15
+ abis: {
16
+ name: string;
17
+ file: string;
18
+ }[];
19
+ eventHandlers?: {
20
+ event: string;
21
+ handler: string;
22
+ topic0?: string;
23
+ }[];
24
+ file: string;
25
+ };
26
+ };
27
+ export declare const validateGraphProtocolSource: (source: unknown) => GraphSource;
@@ -1,35 +1,7 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var validateGraphProtocolSource_exports = {};
24
- __export(validateGraphProtocolSource_exports, {
25
- validateGraphProtocolSource: () => validateGraphProtocolSource,
26
- });
27
- module.exports = __toCommonJS(validateGraphProtocolSource_exports);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateGraphProtocolSource = void 0;
28
4
  const validateGraphProtocolSource = (source) => {
29
- return source;
5
+ return source;
30
6
  };
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 &&
33
- (module.exports = {
34
- validateGraphProtocolSource,
35
- });
7
+ exports.validateGraphProtocolSource = validateGraphProtocolSource;
@@ -0,0 +1,26 @@
1
+ import type { CreatePonderOptions } from "./bin/create-ponder";
2
+ export declare type PonderNetwork = {
3
+ kind?: string;
4
+ name: string;
5
+ chainId: number;
6
+ rpcUrl: string;
7
+ };
8
+ export declare type PonderSource = {
9
+ kind?: "evm";
10
+ name: string;
11
+ network: string;
12
+ abi: string;
13
+ address: string;
14
+ startBlock?: number;
15
+ };
16
+ export declare type PartialPonderConfig = {
17
+ plugins: string[];
18
+ database: {
19
+ kind: string;
20
+ };
21
+ networks: PonderNetwork[];
22
+ sources: PonderSource[];
23
+ };
24
+ export declare const run: (options: CreatePonderOptions, overrides?: {
25
+ installCommand?: string;
26
+ }) => Promise<void>;