-
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.
* feat: rpc module * test: add test for the `rpc` module * style: format * docs: update docs * docs: update other modules * chore: add call method with url * docs: update docs and examples * docs: update examples * chore: code review * docs: update docs and examples * chore: remove call with json params
- Loading branch information
Showing
23 changed files
with
415 additions
and
16 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,34 @@ | ||
## Examples | ||
### Calling an RPC | ||
|
||
Calling an rpc using the `eth_chainId` method | ||
|
||
```solidity | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.13; | ||
import {Test, expect} from "vulcan/test.sol"; | ||
import {rpc} from "vulcan/test/Rpc.sol"; | ||
import {Fork, forks} from "vulcan/test/Forks.sol"; | ||
contract RpcTest is Test { | ||
function testNetVersion() external { | ||
forks.create("https://rpc.mevblocker.io/fast").select(); | ||
string memory method = "eth_chainId"; | ||
string memory params = "[]"; | ||
bytes memory data = rpc.call(method, params); | ||
uint8 chainId; | ||
assembly { | ||
chainId := mload(add(data, 0x01)) | ||
} | ||
expect(chainId).toEqual(block.chainid); | ||
} | ||
} | ||
``` | ||
|
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,7 @@ | ||
# RPC | ||
|
||
The `rpc` module provides methods to interact with JSON-RPC APIs. The list of official Ethereum RPC methods can | ||
be found [here](https://ethereum.org/en/developers/docs/apis/json-rpc). | ||
|
||
{{#include ../examples/rpc/example.md}} | ||
|
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.