Skip to content

Commit

Permalink
feat: support filecoin calibration deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbeckers committed Oct 16, 2024
1 parent 6d9253b commit ac74289
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
},
"dependencies": {
"@hypercerts-org/chainsauce": "1.0.24",
"@hypercerts-org/contracts": "2.0.0-alpha.9",
"@hypercerts-org/contracts": "2.0.0-alpha.10",
"@hypercerts-org/marketplace-sdk": "^0.3.35",
"@hypercerts-org/sdk": "^2.2.0-beta.2",
"@hypercerts-org/sdk": "^2.3.0-beta.1",
"@opentelemetry/instrumentation": "^0.52.1",
"@openzeppelin/merkle-tree": "^1.0.7",
"@supabase/postgrest-js": "^1.15.7",
Expand Down
68 changes: 47 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ const main = async () => {
console.log("🕊️ Seeding contracts...");
await supabase.from("contracts").upsert(
[
{
chain_id: 314159,
contract_address: "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07",
start_block: 2058128,
contract_slug: minterContractSlug,
},
{
chain_id: 42161,
contract_address: "0xcE8fa09562f07c23B9C21b5d0A29a293F8a8BC83",
Expand Down
31 changes: 27 additions & 4 deletions src/clients/evmClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
base,
baseSepolia,
celo,
filecoinCalibration,
optimism,
sepolia,
} from "viem/chains";
Expand All @@ -17,7 +18,8 @@ import {
} from "@/utils/constants.js";

export const getSupportedChains = () => {
if (environment === Environment.TEST) return [11155111, 84532, 421614];
if (environment === Environment.TEST)
return [11155111, 84532, 421614, 314159];
if (environment === Environment.PRODUCTION) return [10, 8453, 42220, 42161];
};

Expand All @@ -37,6 +39,8 @@ const selectedNetwork = (chainId: number) => {
return baseSepolia;
case 11155111:
return sepolia;
case 314159:
return filecoinCalibration;
default:
throw new Error(`Unsupported chain ID: ${chainId}`);
}
Expand All @@ -58,6 +62,8 @@ export const alchemyUrl = (chainId: number) => {
return `https://base-sepolia.g.alchemy.com/v2/${alchemyApiKey}`;
case 11155111:
return `https://eth-sepolia.g.alchemy.com/v2/${alchemyApiKey}`;
case 314159:
return;
default:
throw new Error(`Unsupported chain ID: ${chainId}`);
}
Expand All @@ -78,7 +84,9 @@ const infuraUrl = (chainId: number) => {
case 84532:
return;
case 11155111:
return `https://sepolia.infura.io/v3/${infuraApiKey}`;
return;
case 314159:
return;
default:
throw new Error(`Unsupported chain ID: ${chainId}`);
}
Expand All @@ -100,18 +108,30 @@ const drpcUrl = (chainId: number) => {
return;
case 11155111:
return;
case 314159:
return;
default:
throw new Error(`Unsupported chain ID: ${chainId}`);
}
};

const glifUrl = (chainId: number) => {
switch (chainId) {
case 314159:
return `https://api.calibration.node.glif.io/rpc/v1`;
default:
return;
}
};

const rpc_timeout = 20_000;

export const getRpcUrl = (chainId: number) => {
const alchemy = alchemyUrl(chainId);
const infura = infuraUrl(chainId);
const drpc = drpcUrl(chainId);
return [alchemy, infura, drpc].filter((url) => url)[0];
const glif = glifUrl(chainId);
return [alchemy, infura, drpc, glif].filter((url) => url)[0];
};

const fallBackProvider = (chainId: number) => {
Expand All @@ -124,7 +144,10 @@ const fallBackProvider = (chainId: number) => {
const drpc = drpcUrl(chainId)
? [http(drpcUrl(chainId), { timeout: rpc_timeout })]
: [];
return fallback([...alchemy, ...drpc, ...infura], {
const glif = glifUrl(chainId)
? [http(glifUrl(chainId), { timeout: rpc_timeout })]
: [];
return fallback([...alchemy, ...drpc, ...infura, ...glif], {
retryCount: 5,
});
};
Expand Down
2 changes: 2 additions & 0 deletions src/indexer/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Indexer {

const supportedChains = getSupportedChains();

console.log(supportedChains);

if (!supportedChains || supportedChains.length === 0) {
throw new Error("No supported chains found.");
}
Expand Down
8 changes: 8 additions & 0 deletions src/utils/getDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ export const getDeployment = (
schemaRegistryAddress: "",
chainId,
};
case 314159:
return {
...DEPLOYMENTS["314159"],
startBlock: 2058128n,
easAddress: "",
schemaRegistryAddress: "",
chainId,
};
default:
throw new Error(`Unsupported chain ID: ${chainId}`);
}
Expand Down

0 comments on commit ac74289

Please sign in to comment.