Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
molecula451 committed Mar 1, 2024
1 parent b894bfd commit b2b9201
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"WXDAI",
"XDAI",
"xmark",


"SUPABASE"
],
"dictionaries": ["typescript", "node", "software-terms", "html"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
Expand Down
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
MY_SECRET="MY_SECRET"
SUPABASE_URL=""
SUPBASE_ANON_KEY=""
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
path = lib/ubiquibot
url = https://github.com/ubiquity/ubiquibot
branch = development
[submodule "lib/chainlist"]
path = lib/chainlist
url = https://github.com/DefiLlama/chainlist.git
branch = main
32 changes: 32 additions & 0 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
// @ts-expect-error - Could not find a declaration file for module
import extraRpcs from "../lib/chainlist/constants/extraRpcs";
import esbuild from "esbuild";
import * as dotenv from "dotenv";
const typescriptEntries = ["static/scripts/onboarding/onboarding.ts"];
const cssEntries = ["static/styles/rewards/rewards.css", "static/styles/audit-report/audit.css", "static/styles/onboarding/onboarding.css"];
export const entries = [...typescriptEntries, ...cssEntries];

const allNetworkUrls: Record<string, string[]> = {};
// this flattens all the rpcs into a single object, with key names that match the networkIds. The arrays are just of URLs per network ID.

Object.keys(extraRpcs).forEach((networkId) => {
const officialUrls = extraRpcs[networkId].rpcs.filter((rpc) => typeof rpc === "string");
const extraUrls: string[] = extraRpcs[networkId].rpcs.filter((rpc) => rpc.url !== undefined).map((rpc) => rpc.url);
allNetworkUrls[networkId] = [...officialUrls, ...extraUrls];
});

export const esBuildContext: esbuild.BuildOptions = {
sourcemap: true,
entryPoints: entries,
Expand All @@ -18,6 +29,7 @@ export const esBuildContext: esbuild.BuildOptions = {
".svg": "dataurl",
},
outdir: "static/out",
define: createEnvDefines(["SUPABASE_URL", "SUPABASE_ANON_KEY"], { allNetworkUrls }),
};

esbuild
Expand All @@ -29,3 +41,23 @@ esbuild
console.error(err);
process.exit(1);
});

function createEnvDefines(envVarNames: string[], extras: Record<string, unknown>): Record<string, string> {
const defines: Record<string, string> = {};
dotenv.config();
for (const name of envVarNames) {
const envVar = process.env[name];
if (envVar !== undefined) {
defines[name] = JSON.stringify(envVar);
} else {
throw new Error(`Missing environment variable: ${name}`);
}
}
for (const key in extras) {
if (Object.prototype.hasOwnProperty.call(extras, key)) {
defines[key] = JSON.stringify(extras[key]);
}
}
defines["extraRpcs"] = JSON.stringify(allNetworkUrls);
return defines;
}
1 change: 1 addition & 0 deletions lib/chainlist
Submodule chainlist added at 805928

0 comments on commit b2b9201

Please sign in to comment.