create-ponder 0.0.11 → 0.0.13

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,4 +1,5 @@
1
1
  export declare const getNetworkByEtherscanHostname: (hostname: string) => {
2
2
  name: string;
3
3
  chainId: number;
4
+ apiUrl: string;
4
5
  } | undefined;
@@ -2,20 +2,66 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNetworkByEtherscanHostname = void 0;
4
4
  const networkByEtherscanHostname = {
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 },
5
+ "etherscan.io": {
6
+ name: "mainnet",
7
+ chainId: 1,
8
+ apiUrl: "https://api.etherscan.io/api",
9
+ },
10
+ "ropsten.etherscan.io": {
11
+ name: "ropsten",
12
+ chainId: 3,
13
+ apiUrl: "https://api-ropsten.etherscan.io//api",
14
+ },
15
+ "rinkeby.etherscan.io": {
16
+ name: "rinkeby",
17
+ chainId: 4,
18
+ apiUrl: "https://api-rinkeby.etherscan.io/api",
19
+ },
20
+ "goerli.etherscan.io": {
21
+ name: "goerli",
22
+ chainId: 5,
23
+ apiUrl: "https://api-goerli.etherscan.io/api",
24
+ },
25
+ "kovan.etherscan.io": {
26
+ name: "kovan",
27
+ chainId: 42,
28
+ apiUrl: "https://api-kovan.etherscan.io/api",
29
+ },
30
+ "sepolia.etherscan.io": {
31
+ name: "sepolia",
32
+ chainId: 11155111,
33
+ apiUrl: "https://api-sepolia.etherscan.io/api",
34
+ },
35
+ "optimistic.etherscan.io": {
36
+ name: "optimism",
37
+ chainId: 10,
38
+ apiUrl: "https://api-optimistic.etherscan.io/api",
39
+ },
40
+ "goerli-optimism.etherscan.io": {
41
+ name: "optimism-goerli",
42
+ chainId: 420,
43
+ apiUrl: "https://api-goerli-optimistic.etherscan.io/api",
44
+ },
45
+ "polygonscan.com": {
46
+ name: "polygon",
47
+ chainId: 137,
48
+ apiUrl: "https://api.polygonscan.com/api",
49
+ },
50
+ "mumbai.polygonscan.com": {
51
+ name: "polygon-mumbai",
52
+ chainId: 80001,
53
+ apiUrl: "https://api-testnet.polygonscan.com/api",
54
+ },
55
+ "arbiscan.io": {
56
+ name: "arbitrum",
57
+ chainId: 42161,
58
+ apiUrl: "https://api.arbiscan.io/api",
59
+ },
60
+ "goerli.arbiscan.io": {
61
+ name: "arbitrum-goerli",
62
+ chainId: 421613,
63
+ apiUrl: "https://api-goerli.arbiscan.io/api",
64
+ },
19
65
  };
20
66
  const getNetworkByEtherscanHostname = (hostname) => {
21
67
  return networkByEtherscanHostname[hostname];
package/dist/src/index.js CHANGED
@@ -73,23 +73,18 @@ const run = async (options, overrides = {}) => {
73
73
  }
74
74
  `;
75
75
  (0, node_fs_1.writeFileSync)(node_path_1.default.join(ponderRootDir, `./handlers/index.ts`), prettier_1.default.format(handlerIndexFileContents, { parser: "typescript" }));
76
- // Write the ponder.config.js file.
77
- const finalPonderConfig = `const { graphqlPlugin } = require("@ponder/graphql");
76
+ // Write the ponder.ts file.
77
+ const finalPonderConfig = `
78
+ import type { PonderConfig } from "@ponder/core";
79
+ import { graphqlPlugin } from "@ponder/graphql";
78
80
 
79
- /**
80
- * @type {import('@ponder/core').PonderConfig}
81
- */
82
- const ponderConfig = {
83
- plugins: [graphqlPlugin()],
84
- database: {
85
- kind: "sqlite",
86
- },
87
- networks: ${JSON.stringify(ponderConfig.networks).replaceAll(/"process.env.PONDER_RPC_URL_(.*?)"/g, "process.env.PONDER_RPC_URL_$1")},
88
- sources: ${JSON.stringify(ponderConfig.sources)},
89
- };
90
-
91
- module.exports = ponderConfig;`;
92
- (0, node_fs_1.writeFileSync)(node_path_1.default.join(ponderRootDir, "ponder.config.js"), prettier_1.default.format(finalPonderConfig, { parser: "babel" }));
81
+ export const config: PonderConfig = {
82
+ plugins: [graphqlPlugin()],
83
+ networks: ${JSON.stringify(ponderConfig.networks).replaceAll(/"process.env.PONDER_RPC_URL_(.*?)"/g, "process.env.PONDER_RPC_URL_$1")},
84
+ sources: ${JSON.stringify(ponderConfig.sources)},
85
+ };
86
+ `;
87
+ (0, node_fs_1.writeFileSync)(node_path_1.default.join(ponderRootDir, "ponder.ts"), prettier_1.default.format(finalPonderConfig, { parser: "babel" }));
93
88
  // Write the .env.local file.
94
89
  const uniqueChainIds = Array.from(new Set(ponderConfig.networks.map((n) => n.chainId)));
95
90
  const envLocal = `${uniqueChainIds.map((chainId) => `PONDER_RPC_URL_${chainId}=""\n`)}`;
@@ -22,7 +22,7 @@ const fromEtherscan = async (options) => {
22
22
  if (!network) {
23
23
  throw new Error(`Unrecognized etherscan hostname: ${url.hostname}`);
24
24
  }
25
- const apiUrl = `https://api.${url.hostname}/api`;
25
+ const { name, chainId, apiUrl } = network;
26
26
  const contractAddress = url.pathname.slice(1).split("/")[1];
27
27
  const txHash = await getContractCreationTxn(contractAddress, apiUrl, apiKey);
28
28
  if (!apiKey) {
@@ -56,15 +56,15 @@ const fromEtherscan = async (options) => {
56
56
  },
57
57
  networks: [
58
58
  {
59
- name: network.name,
60
- chainId: network.chainId,
61
- rpcUrl: `process.env.PONDER_RPC_URL_${network.chainId}`,
59
+ name: name,
60
+ chainId: chainId,
61
+ rpcUrl: `process.env.PONDER_RPC_URL_${chainId}`,
62
62
  },
63
63
  ],
64
64
  sources: [
65
65
  {
66
66
  name: contractName,
67
- network: network.name,
67
+ network: name,
68
68
  abi: abiRelativePath,
69
69
  address: contractAddress,
70
70
  startBlock: blockNumber,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ponder",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Tool to bootstrap a Ponder project",
5
5
  "license": "MIT",
6
6
  "author": "olias.eth",
@@ -29,7 +29,7 @@
29
29
  "jest": "^29.3.1",
30
30
  "tsconfig-replace-paths": "^0.0.11",
31
31
  "typescript": "^4.5.5",
32
- "@ponder/core": "0.0.22"
32
+ "@ponder/core": "0.0.24"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "rm -rf dist && tsc && tsconfig-replace-paths --src . && mv dist/src/bin/create-ponder.js dist/src/bin/create-ponder",