Skip to content

Commit

Permalink
chore: merge from main and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Feb 29, 2024
2 parents a5855f7 + 065b1eb commit 75cb97a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
16 changes: 9 additions & 7 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import * as dotenv from "dotenv";
import esbuild from "esbuild";
import extraRpcs from "../lib/chainlist/constants/extraRpcs";

import * as dotenv from "dotenv";
import esbuild from "esbuild";
import chainlist from "../lib/chainlist/constants/extraRpcs";
const typescriptEntries = [
"static/scripts/rewards/init.ts",
"static/scripts/audit-report/audit.ts",
Expand All @@ -12,14 +15,13 @@ const typescriptEntries = [
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[]> = {};
const extraRpcs: 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 && rpc.tracking === "none").map((rpc) => rpc.url);

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

export const esBuildContext: esbuild.BuildOptions = {
Expand All @@ -37,7 +39,7 @@ export const esBuildContext: esbuild.BuildOptions = {
},
outdir: "static/out",
define: createEnvDefines(["SUPABASE_URL", "SUPABASE_ANON_KEY"], {
extraRpcs: allNetworkUrls,
extraRpcs,
commitHash: execSync(`git rev-parse --short HEAD`).toString().trim(),
}),
};
Expand Down
16 changes: 16 additions & 0 deletions scripts/typescript/multi-permits.t.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { generateERC20Permit } from "./generate-permit2-url";
import { log, verifyEnvironmentVariables } from "./utils";

export async function generateMultiERC20Permits() {
for (let i = 0; i < 5; i++) {
const url = await generateERC20Permit();
log.ok("Testing URL:");
console.log(url);
}
}

generateMultiERC20Permits().catch((error) => {
console.error(error);
verifyEnvironmentVariables();
process.exitCode = 1;
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { claimErc20PermitHandlerWrapper, fetchFundingWallet, generateInvalidateP
import { claimErc721PermitHandler } from "../web3/erc721-permit";
import { verifyCurrentNetwork } from "../web3/verify-current-network";
import { insertErc20PermitTableData, insertErc721PermitTableData } from "./insert-table-data";
import { displayRewardDetails, displayRewardPagination } from "./read-claim-data-from-url";
import { renderEnsName } from "./render-ens-name";
import { renderNftSymbol, renderTokenSymbol } from "./render-token-symbol";
import { setPagination } from "./set-pagination";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function getFastestRpcProvider(networkId: number) {
const sortedLatencies = validLatencies.sort((a, b) => a[1] - b[1]);
const optimalRPC = sortedLatencies[0][0];

console.log(`Fastest RPC for network ${networkId} is ${optimalRPC}`);
return new ethers.providers.JsonRpcProvider(optimalRPC, {
name: optimalRPC,
chainId: networkId,
Expand Down
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"include": ["src", "lib/chainlist/constants/extraRpcs.js", "static", "build", "scripts/typescript", "globals.d.ts"],
"include": [
"src",
"lib/chainlist/constants/extraRpcs.js",
"static",
"build",
"scripts/typescript",
"globals.d.ts"
],
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
Expand Down Expand Up @@ -99,4 +106,4 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
}

0 comments on commit 75cb97a

Please sign in to comment.