-
Notifications
You must be signed in to change notification settings - Fork 5k
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
7246 drpcprovider #7252
Open
jdevcs
wants to merge
8
commits into
4.x
Choose a base branch
from
junaid/7246drpcprovider
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
7246 drpcprovider #7252
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d743c4f
DRPCProvider
jdevcs 4aad732
default provider
jdevcs 39f9648
ZK network
jdevcs 665867b
test and update
jdevcs b0100fa
test updates in draft PR
jdevcs 276092f
added test
jdevcs f2f2974
update getRPCURL
jdevcs c1c78ff
Update dRPC Provider with API Key (#7352)
danforbes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
This file is part of web3.js. | ||
|
||
web3.js is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
web3.js is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with web3.js. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { HttpProviderOptions } from 'web3-providers-http'; | ||
import { Transport, Network, SocketOptions } from './types.js'; | ||
import { Web3ExternalProvider } from './web3_provider.js'; | ||
|
||
export class DRPCProvider extends Web3ExternalProvider { | ||
// eslint-disable-next-line default-param-last | ||
public constructor( | ||
network: Network = Network.ETH_MAINNET, | ||
transport: Transport = Transport.HTTPS, | ||
token = 'TEST_TOKEN', | ||
host = 'lb.drpc.org', | ||
providerConfigOptions?: HttpProviderOptions | SocketOptions, | ||
) { | ||
super(network, transport, token, host, providerConfigOptions); | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
public getRPCURL(network: Network, transport: Transport, key: string, host: string) { | ||
let networkString = ''; | ||
|
||
switch (network) { | ||
case Network.ETH_MAINNET: | ||
networkString = 'ethereum'; | ||
break; | ||
case Network.ETH_SEPOLIA: | ||
networkString = 'sepolia'; | ||
break; | ||
case Network.ETH_HOLESKY: | ||
networkString = 'holesky'; | ||
break; | ||
|
||
case Network.ARBITRUM_MAINNET: | ||
networkString = 'arbitrum'; | ||
break; | ||
case Network.ARBITRUM_SEPOLIA: | ||
networkString = 'arbitrum-sepolia'; | ||
break; | ||
|
||
case Network.BNB_MAINNET: | ||
networkString = 'bsc'; | ||
break; | ||
case Network.BNB_TESTNET: | ||
networkString = 'bsc-testnet'; | ||
break; | ||
|
||
case Network.POLYGON_MAINNET: | ||
networkString = 'polygon'; | ||
break; | ||
case Network.POLYGON_AMONY: | ||
networkString = 'polygon-amoy'; | ||
break; | ||
|
||
case Network.ZKERA_MAINNET: | ||
networkString = 'zksync'; | ||
break; | ||
|
||
case Network.ZKERA_SEPOLIA: | ||
networkString = 'zksync-sepolia'; | ||
break; | ||
|
||
default: | ||
throw new Error('Network info not available.'); | ||
} | ||
|
||
let protocol = ''; | ||
|
||
if (transport === Transport.HTTPS) { | ||
protocol = 'rpc'; | ||
} else if (transport === Transport.WebSocket) { | ||
protocol = 'ws'; | ||
} | ||
|
||
return `${transport}://${host}/og${protocol}?network=${networkString}&dkey=${key}`; | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
few tests skipped until web3.js specific public key is added in this PR