-
Notifications
You must be signed in to change notification settings - Fork 21
Feat/rpc handler #19
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/rpc handler #19
Changes from all commits
fc02db1
1d84ab9
7f1ebc3
9247e58
91470cc
67338e3
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// @ts-expect-error - no types | ||
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.
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. The repo does but the package does not for some reason. My test pkg I published has types and it's the same flow that was used to publish but the UBQ pkg doesn't have types in either of the versions on npmjs https://www.npmjs.com/package/@ubiquity-dao/rpc-handler?activeTab=code |
||
import { RPCHandler, HandlerConstructorConfig } from "@ubiquity-dao/rpc-handler" | ||
import { JsonRpcProvider } from "ethers"; | ||
|
||
function getHandler(networkId: number | string) { | ||
const config = { | ||
networkId, | ||
autoStorage: false, | ||
cacheRefreshCycles: 5, | ||
rpcTimeout: 1500, | ||
networkName: null, | ||
runtimeRpcs: null, | ||
networkRpcs: null, | ||
}; | ||
|
||
return new RPCHandler(config as HandlerConstructorConfig) | ||
} | ||
|
||
export async function getFastestProvider(networkId: number | string): Promise<JsonRpcProvider> { | ||
try { | ||
const handler = getHandler(networkId) | ||
return await handler.getFastestRpcProvider() | ||
} catch (e) { | ||
throw new Error(`Failed to get fastest provider for networkId: ${networkId}`) | ||
} | ||
} |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.