generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from ubq-testing/feat/rpc-handler
- Loading branch information
Showing
8 changed files
with
7,041 additions
and
10,510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// @ts-expect-error - no types | ||
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.