-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: call db to retrieve permits instead of parsing github comments #164
Changes from 1 commit
35d0b99
7528f3e
2b21d66
655ead5
72b23f2
3b7c3d2
2f11234
0878552
a1c6e4b
0ba50af
5a504fd
ba87b12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,45 @@ export const getRandomRpcUrl = (chain: Chain): string => { | |
return urls[randomIndex]; | ||
}; | ||
|
||
const verifyBlock = (data: DataType) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to merge in the latest lint rules ASAP from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code got merged from the dev branch, not on me 😅 |
||
try { | ||
const { jsonrpc, id, result } = data; | ||
const { number, timestamp, hash } = result; | ||
return jsonrpc === "2.0" && id === 1 && parseInt(number, 16) > 0 && parseInt(timestamp, 16) > 0 && hash.match(/[0-9|a-f|A-F|x]/gm)?.join("").length === 66; | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
|
||
export const getOptimalRPC = async (chain: Chain): Promise<string> => { | ||
const promises = RPC_URLS[chain].map(async (baseURL: string) => { | ||
try { | ||
const startTime = performance.now(); | ||
const API = axios.create({ | ||
baseURL, | ||
headers: RPC_HEADER, | ||
}); | ||
|
||
const { data } = await API.post("", RPC_BODY); | ||
const endTime = performance.now(); | ||
const latency = endTime - startTime; | ||
if (await verifyBlock(data)) { | ||
return Promise.resolve({ | ||
latency, | ||
baseURL, | ||
}); | ||
} else { | ||
return Promise.reject(); | ||
} | ||
} catch (error) { | ||
return Promise.reject(); | ||
} | ||
}); | ||
|
||
const { baseURL: optimalRPC } = await Promise.any(promises); | ||
return optimalRPC; | ||
}; | ||
|
||
export const parseRepoUrl = (issueUrl: string): [string, string] => { | ||
const match = issueUrl.match(/github\.com\/([^/]+)\/([^/]+)\/issues\/\d+/i); | ||
if (match) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you need to redo fixing the merge conflict