Skip to content

Commit

Permalink
changes to support 2 separate sepolia contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
hubsmoke committed Mar 15, 2024
1 parent 9e5d18a commit 3579441
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PORT=5460
SUPABASE_URL=
SUPABASE_KEY=
SUPABASE_KEY=
DPID_ENV=dev
1 change: 1 addition & 0 deletions kubernetes/deployment.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
{{- with secret "secrets/dpid-resolver/dev" -}}
echo "appstart";
export NODE_ENV=production
export ENV=dev
export SUPABASE_URL={{ .Data.SUPABASE_URL }}
export SUPABASE_KEY={{ .Data.SUPABASE_KEY }}
export DEBUG_TEST=0;
Expand Down
24 changes: 20 additions & 4 deletions src/dpid-reader/DpidReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,22 @@ export const DEFAULT_IPFS_GATEWAY = "https://ipfs.desci.com/ipfs";
// the value of string "beta" in bytes32 encoded as hex
export const PREFIX_HARDCODE_BETA = "0x6265746100000000000000000000000000000000000000000000000000000000";

export const THE_GRAPH_RESOLVER_URL: { [key: string]: string } = {
beta: "https://graph-goerli-stage.desci.com/subgraphs/name/nodes",
__registry: "https://graph-goerli-stage.desci.com/subgraphs/name/dpid-registry",
};
export const THE_GRAPH_RESOLVER_URL: { [key: string]: string } =
process.env.DPID_ENV === "dev"
? {
beta: "https://graph-sepolia-dev.desci.com/subgraphs/name/nodes",
__registry: "https://graph-sepolia-dev.desci.com/subgraphs/name/dpid-registry",
}
: {
beta: "https://graph-goerli-stage.desci.com/subgraphs/name/nodes",
__registry: "https://graph-goerli-stage.desci.com/subgraphs/name/dpid-registry",
};

logger.info({
THE_GRAPH_RESOLVER_URL,
PREFIX_HARDCODE_BETA,
DEFAULT_IPFS_GATEWAY,
});

interface ContractConfig {
address: string;
Expand Down Expand Up @@ -100,6 +112,7 @@ export const hexToCid = (hexCid: string) => {
export interface DataResponse {
data: object;
}
// TODO: remove sealstorage specific cert, no longer needed
const caBundle = fs.readFileSync("ssl/sealstorage-bundle.crt");
const agent = new https.Agent({ ca: caBundle, rejectUnauthorized: false });
export class DpidReader {
Expand Down Expand Up @@ -205,16 +218,19 @@ export class DpidReader {

const arg = `${dataBucket.payload.cid}${dataSuffix ? `/${dataSuffix}` : ""}`
.replace("?raw", "")
// temporary logic to reroute to a different IPFS gateway for certain datasets
.replace(
"bafybeiamtbqbtq6xq3qmj7sod6dygilxn2eztlgy3p7xctje6jjjbsdah4/Data",
"bafybeidmlofidcypbqcbjejpm6u472vbhwue2jebyrfnyymws644seyhdq"
)
// temporary logic to reroute to a different IPFS gateway for certain datasets
.replace(
"bafybeibi6wxfwa6mw5xlctezx2alaq4ookmld25pfqy3okbnfz4kkxtk4a/Data",
"bafybeidmlofidcypbqcbjejpm6u472vbhwue2jebyrfnyymws644seyhdq"
);
logger.info({ arg, dataBucket }, "arg");

// temporary logic to reroute to a different IPFS gateway for certain datasets
const CID_MAP: { [key: string]: string } = {
bafybeiamtbqbtq6xq3qmj7sod6dygilxn2eztlgy3p7xctje6jjjbsdah4: "https://ipfs.io/ipfs",
bafybeibi6wxfwa6mw5xlctezx2alaq4ookmld25pfqy3okbnfz4kkxtk4a: "https://ipfs.io/ipfs",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ app.get("/*", async (req: Request, res: Response) => {

const hostnameToPrefix: { [hostname: string]: string } = {
"beta.dpid.org": "beta",
"beta-dev.dpid.org": "beta-dev",
"beta-dev.dpid.org": "beta",
"dev-beta.dpid.org": "beta",
"dev-beta-dev.dpid": "beta-dev",
"dev-beta-dev.dpid": "beta",
};
const prefix = hostnameToPrefix[hostname] || "beta";

Expand Down

0 comments on commit 3579441

Please sign in to comment.