-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: Consolidate RetryProvider cast in RPCUtils (#895)
Makes it easier to use the convertEthersRPCToZKSyncRPC() helper.
- Loading branch information
Showing
4 changed files
with
11 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * as zkSync from "./zkSync"; |
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import assert from "assert"; | ||
import { providers as ethersProviders } from "ethers"; | ||
import { Provider as ZKSyncProvider } from "zksync-web3"; | ||
import { isDefined } from "./TypeGuards"; | ||
import { RetryProvider } from "./ProviderUtils"; | ||
import { RetryProvider } from "../ProviderUtils"; | ||
import { isDefined } from "../TypeGuards"; | ||
|
||
/** | ||
* Converts a valid Ethers Provider into a ZKSync Provider | ||
* @param ethersProvider The Ethers provider that we wish to convert | ||
* @returns A ZKSync Provider | ||
* @throws If the provider is not a valid JsonRpcProvider | ||
*/ | ||
export function convertEthersRPCToZKSyncRPC(ethersProvider: RetryProvider): ZKSyncProvider { | ||
export function convertEthersRPCToZKSyncRPC(ethersProvider: ethersProviders.Provider): ZKSyncProvider { | ||
const url = (ethersProvider as RetryProvider).providers[0].connection.url; | ||
assert(isDefined(url), "Provider must be of type JsonRpcProvider"); | ||
assert(isDefined(url), "Provider must be of type RetryProvider"); | ||
return new ZKSyncProvider(url); | ||
} |
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