Skip to content

Commit

Permalink
fix: no network resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Feb 26, 2024
1 parent 6f3bfdf commit 16a534e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
4 changes: 2 additions & 2 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ 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"];
const blacklist = ["https://xdai-archive.blockscout.com", "https://gnosis.api.onfinality.io/public"];

Object.keys(extraRpcs).forEach((networkId) => {
const officialUrls = extraRpcs[networkId].rpcs.filter((rpc) => {
if (typeof rpc === "string") {
if (blacklist.includes(rpc)) {
return "";
return null;
} else {
return rpc;
}
Expand Down
12 changes: 2 additions & 10 deletions scripts/typescript/generate-permit2-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ dotenv.config();

const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; // same on all chains

generate().catch((error) => {
generateERC20Permit().catch((error) => {
console.error(error);
verifyEnvironmentVariables();
process.exitCode = 1;
});

async function generate(multi = false) {
export async function generateERC20Permit(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 @@ -70,11 +70,3 @@ async function generate(multi = false) {
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);
}
}
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;
});
5 changes: 5 additions & 0 deletions static/scripts/rewards/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum NetworkIds {
Mainnet = 1,
Goerli = 5,
Gnosis = 100,
Anvil = 31337,
}

export enum Tokens {
Expand All @@ -19,12 +20,14 @@ export const networkNames = {
[NetworkIds.Mainnet]: "Ethereum Mainnet",
[NetworkIds.Goerli]: "Goerli Testnet",
[NetworkIds.Gnosis]: "Gnosis Chain",
[NetworkIds.Anvil]: "http://127.0.0.1:8545",
};

export const networkCurrencies: Record<number, object> = {
[NetworkIds.Mainnet]: { symbol: "ETH", decimals: 18 },
[NetworkIds.Goerli]: { symbol: "GoerliETH", decimals: 18 },
[NetworkIds.Gnosis]: { symbol: "XDAI", decimals: 18 },
[NetworkIds.Anvil]: { symbol: "XDAI", decimals: 18 },
};

export function getNetworkName(networkId?: number) {
Expand All @@ -39,12 +42,14 @@ export const networkExplorers: Record<number, string> = {
[NetworkIds.Mainnet]: "https://etherscan.io",
[NetworkIds.Goerli]: "https://goerli.etherscan.io",
[NetworkIds.Gnosis]: "https://gnosisscan.io",
[NetworkIds.Anvil]: "https://gnosisscan.io",
};

export const networkRpcs: Record<number, string[]> = {
[NetworkIds.Mainnet]: ["https://rpc-pay.ubq.fi/v1/mainnet", ...(extraRpcs[NetworkIds.Mainnet] || [])],
[NetworkIds.Goerli]: ["https://rpc-pay.ubq.fi/v1/goerli", ...(extraRpcs[NetworkIds.Goerli] || [])],
[NetworkIds.Gnosis]: [...(extraRpcs[NetworkIds.Gnosis] || [])],
[NetworkIds.Anvil]: ["http://127.0.0.1:8545", ""],
};

export const permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
Expand Down
7 changes: 7 additions & 0 deletions static/scripts/rewards/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export async function getErc20Contract(contractAddress: string, provider: JsonRp
}

export async function getOptimalProvider(networkId: number) {
if (networkId === 31337)
return new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545", {
name: "http://127.0.0.1:8545",
chainId: 31337,
ensAddress: "",
});

const promises = networkRpcs[networkId].map(async (baseURL: string) => {
try {
const startTime = performance.now();
Expand Down

0 comments on commit 16a534e

Please sign in to comment.