create-ponder 0.5.0 → 0.5.1
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.
- package/dist/index.js +48 -18
- package/package.json +1 -1
- package/templates/empty/ponder.config.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { default as prompts } from "prompts";
|
|
|
16
16
|
// package.json
|
|
17
17
|
var package_default = {
|
|
18
18
|
name: "create-ponder",
|
|
19
|
-
version: "0.5.
|
|
19
|
+
version: "0.5.1",
|
|
20
20
|
type: "module",
|
|
21
21
|
description: "A CLI tool to create Ponder apps",
|
|
22
22
|
license: "MIT",
|
|
@@ -484,8 +484,6 @@ var chainIdByGraphNetwork = {
|
|
|
484
484
|
fantom: 250,
|
|
485
485
|
"fantom-testnet": 4002,
|
|
486
486
|
bsc: 56,
|
|
487
|
-
chapel: -1,
|
|
488
|
-
clover: 0,
|
|
489
487
|
avalanche: 43114,
|
|
490
488
|
fuji: 43113,
|
|
491
489
|
celo: 42220,
|
|
@@ -493,7 +491,6 @@ var chainIdByGraphNetwork = {
|
|
|
493
491
|
fuse: 122,
|
|
494
492
|
moonbeam: 1284,
|
|
495
493
|
moonriver: 1285,
|
|
496
|
-
mbase: -1,
|
|
497
494
|
base: 8453,
|
|
498
495
|
"base-sepolia": 84532,
|
|
499
496
|
"arbitrum-one": 42161,
|
|
@@ -504,7 +501,7 @@ var chainIdByGraphNetwork = {
|
|
|
504
501
|
"aurora-testnet": 1313161555
|
|
505
502
|
};
|
|
506
503
|
var getGraphProtocolChainId = (networkName) => {
|
|
507
|
-
return chainIdByGraphNetwork[networkName];
|
|
504
|
+
return chainIdByGraphNetwork[networkName] ?? 0;
|
|
508
505
|
};
|
|
509
506
|
var subgraphYamlFileNames = ["subgraph.yaml"].concat(
|
|
510
507
|
Object.keys(chainIdByGraphNetwork).map((n) => `subgraph-${n}.yaml`)
|
|
@@ -516,17 +513,33 @@ var validateGraphProtocolSource = (source) => {
|
|
|
516
513
|
};
|
|
517
514
|
|
|
518
515
|
// src/subgraph.ts
|
|
519
|
-
var
|
|
520
|
-
|
|
516
|
+
var subgraphProviders = [
|
|
517
|
+
{
|
|
518
|
+
id: "thegraph",
|
|
519
|
+
name: "The Graph",
|
|
520
|
+
getUrl: (cid) => `https://ipfs.network.thegraph.com/api/v0/cat?arg=${cid}`
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: "satsuma",
|
|
524
|
+
name: "Alchemy Subgraph (Satsuma)",
|
|
525
|
+
getUrl: (cid) => `https://ipfs.satsuma.xyz/ipfs/${cid}`
|
|
526
|
+
}
|
|
527
|
+
];
|
|
528
|
+
var fetchIpfsFile = async (cid, subgraphProvider) => {
|
|
529
|
+
const url = subgraphProvider.getUrl(cid);
|
|
521
530
|
const response = await fetch(url);
|
|
522
531
|
const contentRaw = await response.text();
|
|
523
532
|
return contentRaw;
|
|
524
533
|
};
|
|
525
534
|
var fromSubgraphId = async ({
|
|
526
535
|
rootDir,
|
|
527
|
-
subgraphId
|
|
536
|
+
subgraphId,
|
|
537
|
+
subgraphProvider = "thegraph"
|
|
528
538
|
}) => {
|
|
529
|
-
const
|
|
539
|
+
const provider = subgraphProviders.find((p) => p.id === subgraphProvider);
|
|
540
|
+
if (!provider)
|
|
541
|
+
throw new Error(`Unknown subgraph provider: ${subgraphProvider}`);
|
|
542
|
+
const manifestRaw = await fetchIpfsFile(subgraphId, provider);
|
|
530
543
|
const manifest = parse(manifestRaw);
|
|
531
544
|
const contracts = {};
|
|
532
545
|
manifest.dataSources.forEach((d) => {
|
|
@@ -545,7 +558,7 @@ var fromSubgraphId = async ({
|
|
|
545
558
|
const abis = {};
|
|
546
559
|
await Promise.all(
|
|
547
560
|
abiFiles.map(async (abi) => {
|
|
548
|
-
const abiContent = await fetchIpfsFile(abi.file["/"].slice(6));
|
|
561
|
+
const abiContent = await fetchIpfsFile(abi.file["/"].slice(6), provider);
|
|
549
562
|
const abiPath = path3.join(rootDir, `./abis/${abi.name}Abi.ts`);
|
|
550
563
|
writeFileSync2(
|
|
551
564
|
abiPath,
|
|
@@ -562,10 +575,6 @@ var fromSubgraphId = async ({
|
|
|
562
575
|
const ponderContracts = dataSources.map((sourceInvalid) => {
|
|
563
576
|
const source = validateGraphProtocolSource(sourceInvalid);
|
|
564
577
|
const network = source.network || "mainnet";
|
|
565
|
-
const chainId = getGraphProtocolChainId(network);
|
|
566
|
-
if (!chainId || chainId === -1) {
|
|
567
|
-
throw new Error(`Unhandled network name: ${network}`);
|
|
568
|
-
}
|
|
569
578
|
const abiRelativePath = `./abis/${source.source.abi}Abi.ts`;
|
|
570
579
|
return {
|
|
571
580
|
name: source.name,
|
|
@@ -582,10 +591,11 @@ var fromSubgraphId = async ({
|
|
|
582
591
|
const contractsObject = {};
|
|
583
592
|
const networksObject = {};
|
|
584
593
|
ponderContracts.forEach((pc) => {
|
|
594
|
+
const chainId = getGraphProtocolChainId(pc.network);
|
|
585
595
|
contractsObject[pc.name] = pc;
|
|
586
596
|
networksObject[pc.network] = {
|
|
587
|
-
chainId
|
|
588
|
-
transport: `http(process.env.PONDER_RPC_URL_${
|
|
597
|
+
chainId,
|
|
598
|
+
transport: `http(process.env.PONDER_RPC_URL_${chainId})`
|
|
589
599
|
};
|
|
590
600
|
contractsObject[pc.name].name = void 0;
|
|
591
601
|
});
|
|
@@ -781,7 +791,20 @@ async function run({
|
|
|
781
791
|
}
|
|
782
792
|
}
|
|
783
793
|
let subgraph = options.subgraph;
|
|
794
|
+
let subgraphProvider = options.subgraphProvider;
|
|
784
795
|
if (templateMeta.id === "subgraph") {
|
|
796
|
+
if (subgraphProvider === void 0) {
|
|
797
|
+
const result = await prompts({
|
|
798
|
+
name: "subgraphProvider",
|
|
799
|
+
message: "Which provider is the subgraph deployed to?",
|
|
800
|
+
type: "select",
|
|
801
|
+
choices: subgraphProviders.map(({ id, name }) => ({
|
|
802
|
+
title: name,
|
|
803
|
+
value: id
|
|
804
|
+
}))
|
|
805
|
+
});
|
|
806
|
+
subgraphProvider = result.subgraphProvider;
|
|
807
|
+
}
|
|
785
808
|
if (!subgraph) {
|
|
786
809
|
const result = await prompts({
|
|
787
810
|
type: "text",
|
|
@@ -816,7 +839,11 @@ async function run({
|
|
|
816
839
|
}
|
|
817
840
|
if (templateMeta.id === "subgraph") {
|
|
818
841
|
const result = await oraPromise(
|
|
819
|
-
fromSubgraphId({
|
|
842
|
+
fromSubgraphId({
|
|
843
|
+
rootDir: projectPath,
|
|
844
|
+
subgraphId: subgraph,
|
|
845
|
+
subgraphProvider
|
|
846
|
+
}),
|
|
820
847
|
{
|
|
821
848
|
text: "Fetching subgraph metadata. This may take a few seconds.",
|
|
822
849
|
failText: "Failed to fetch subgraph metadata.",
|
|
@@ -972,7 +999,10 @@ async function run({
|
|
|
972
999
|
const cli = cac(package_default.name).version(package_default.version).usage(`${pico5.green("<directory>")} [options]`).option(
|
|
973
1000
|
"-t, --template [id]",
|
|
974
1001
|
`Use a template. Options: ${templates.map(({ id }) => id).join(", ")}`
|
|
975
|
-
).option("--etherscan [url]", "Use the Etherscan template").option("--subgraph [id]", "Use the subgraph template").option(
|
|
1002
|
+
).option("--etherscan [url]", "Use the Etherscan template").option("--subgraph [id]", "Use the subgraph template").option(
|
|
1003
|
+
"--subgraph-provider [provider]",
|
|
1004
|
+
`Specify the subgraph provider. Options: ${subgraphProviders.map(({ id }) => id).join(", ")}`
|
|
1005
|
+
).option("--npm", "Use npm as your package manager").option("--pnpm", "Use pnpm as your package manager").option("--yarn", "Use yarn as your package manager").option("--skip-git", "Skip initializing a git repository").option(
|
|
976
1006
|
"--etherscan-api-key [key]",
|
|
977
1007
|
"Etherscan API key for Etherscan template"
|
|
978
1008
|
).help();
|
package/package.json
CHANGED