Skip to content

Commit

Permalink
fix: rpc blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Feb 23, 2024
1 parent 517dd48 commit 1fe025d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
31 changes: 29 additions & 2 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @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";
Expand All @@ -13,9 +14,35 @@ 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.

const blacklist = ["https://xdai-archive.blockscout.com"];

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);
const officialUrls = extraRpcs[networkId].rpcs.filter((rpc) => {
if (typeof rpc === "string") {
if (blacklist.includes(rpc)) {
return "";
} else {
return rpc;
}
}
});
const extraUrls: string[] = extraRpcs[networkId].rpcs
.filter((rpc) => rpc.url !== undefined)
.map((rpc) => {
if (typeof rpc === "string") {
if (blacklist.includes(rpc)) {
return "";
} else {
return rpc;
}
} else {
if (blacklist.includes(rpc.url)) {
return "";
} else {
return rpc.url;
}
}
});
allNetworkUrls[networkId] = [...officialUrls, ...extraUrls];
});

Expand Down
25 changes: 19 additions & 6 deletions scripts/typescript/generate-permit2-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generate().catch((error) => {
process.exitCode = 1;
});

async function generate() {
async function generate(multi = false) {
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_PROVIDER_URL);
const myWallet = new ethers.Wallet(process.env.UBIQUIBOT_PRIVATE_KEY || "", provider);

Expand Down Expand Up @@ -59,9 +59,22 @@ async function generate() {
];

const base64encodedTxData = Buffer.from(JSON.stringify(txData)).toString("base64");
log.ok("Testing URL:");
console.log(`${process.env.FRONTEND_URL}?claim=${base64encodedTxData}`);
log.ok("Public URL:");
console.log(`https://pay.ubq.fi?claim=${base64encodedTxData}`);
console.log();

if (multi) {
return `${process.env.FRONTEND_URL}?claim=${base64encodedTxData}`;
} else {
log.ok("Testing URL:");
console.log(`${process.env.FRONTEND_URL}?claim=${base64encodedTxData}`);
log.ok("Public URL:");
console.log(`https://pay.ubq.fi?claim=${base64encodedTxData}`);
console.log();
}
}

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

0 comments on commit 1fe025d

Please sign in to comment.