Skip to content

Commit

Permalink
add mainnet and sepolia as supported chains
Browse files Browse the repository at this point in the history
  • Loading branch information
alecananian committed May 15, 2024
1 parent 08d18de commit 391568e
Show file tree
Hide file tree
Showing 6 changed files with 1,368 additions and 1,788 deletions.
79 changes: 41 additions & 38 deletions apps/api/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Prisma } from "@prisma/client";
import { PrismaClient } from "@prisma/client";
import { type Contract, getContractAddress } from "@treasure-dev/tdk-core";
import { arbitrum, arbitrumSepolia } from "viem/chains";
import { arbitrum, arbitrumSepolia, sepolia } from "viem/chains";

type Environment = "local" | "dev" | "prod";

Expand Down Expand Up @@ -46,20 +46,33 @@ const REDIRECT_URIS: Record<string, Record<Environment, string[]>> = {
},
};

const CALL_TARGETS: Record<string, Contract[]> = {
app: [],
realm: ["MAGIC"],
const CALL_TARGETS: Record<string, [number, Contract][]> = {
app: [
[arbitrumSepolia.id, "MAGIC"],
[sepolia.id, "MAGIC"],
],
realm: [[arbitrumSepolia.id, "MAGIC"]],
zeeverse: [
"MAGIC",
"Consumables",
"Legions",
"CorruptionRemoval",
"ERC1155TokenSetCorruptionHandler",
"HarvesterEmberwing",
"NftHandlerEmberwing",
"ZeeverseZee",
"ZeeverseItems",
"BulkTransferHelper",
[arbitrumSepolia.id, "MAGIC"],
[arbitrumSepolia.id, "Consumables"],
[arbitrumSepolia.id, "Legions"],
[arbitrumSepolia.id, "CorruptionRemoval"],
[arbitrumSepolia.id, "ERC1155TokenSetCorruptionHandler"],
[arbitrumSepolia.id, "HarvesterEmberwing"],
[arbitrumSepolia.id, "NftHandlerEmberwing"],
[arbitrumSepolia.id, "ZeeverseZee"],
[arbitrumSepolia.id, "ZeeverseItems"],
[arbitrumSepolia.id, "BulkTransferHelper"],
[arbitrum.id, "MAGIC"],
[arbitrum.id, "Consumables"],
[arbitrum.id, "Legions"],
[arbitrum.id, "CorruptionRemoval"],
[arbitrum.id, "ERC1155TokenSetCorruptionHandler"],
[arbitrum.id, "HarvesterEmberwing"],
[arbitrum.id, "NftHandlerEmberwing"],
[arbitrum.id, "ZeeverseZee"],
[arbitrum.id, "ZeeverseItems"],
[arbitrum.id, "BulkTransferHelper"],
],
};

Expand All @@ -74,38 +87,28 @@ const createProject = ({
slug: string;
metadata: ProjectMetadata;
redirectUris?: string[];
callTargets?: Contract[];
callTargets?: [number, Contract][];
}) => {
const data = {
...metadata,
slug,
redirectUris,
callTargets: {
connectOrCreate: callTargets.flatMap((contract) => {
const testnetCallTarget = {
chainId: arbitrumSepolia.id,
address: getContractAddress(arbitrumSepolia.id, contract),
};

const mainnetCallTarget = {
chainId: arbitrum.id,
address: getContractAddress(arbitrum.id, contract),
};
connectOrCreate: callTargets.map(([chainId, contract]) => {
const address = getContractAddress(chainId, contract);
if (!address) {
throw new Error(
`Contract address not found for ${contract} on chain ${chainId}`,
);
}

return [
{
where: {
chainId_address: testnetCallTarget,
},
create: testnetCallTarget,
},
{
where: {
chainId_address: mainnetCallTarget,
},
create: mainnetCallTarget,
const callTarget = { chainId, address };
return {
where: {
chainId_address: callTarget,
},
];
create: callTarget,
};
}),
},
} as const;
Expand Down
Loading

0 comments on commit 391568e

Please sign in to comment.