-
Notifications
You must be signed in to change notification settings - Fork 6
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 #147 from lidofinance/develop
Develop to main
- Loading branch information
Showing
44 changed files
with
2,265 additions
and
8 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,46 @@ | ||
name: Publish Dry Run | ||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
secrets: | ||
NPM_TOKEN: | ||
description: 'NPM token' | ||
required: true | ||
|
||
jobs: | ||
publish-dry-run: | ||
runs-on: ubuntu-latest | ||
environment: development | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn --immutable | ||
|
||
- name: Build | ||
run: yarn build:packages | ||
|
||
- name: Dry run Publish | ||
run: yarn multi-semantic-release --dry-run --silent | grep -E '#|###|\*' > dry_run_output.txt | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Write results to summary | ||
run: | | ||
if [ -s dry_run_output.txt ]; then | ||
echo "# Packages to be published:" >> $GITHUB_STEP_SUMMARY | ||
cat dry_run_output.txt >> $GITHUB_STEP_SUMMARY | ||
else | ||
echo "Nothing will be published" >> $GITHUB_STEP_SUMMARY | ||
fi |
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,7 @@ | ||
{ | ||
"label": "Erlang Bridge", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index" | ||
} | ||
} |
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,21 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Installation | ||
|
||
## Installing Erlang | ||
|
||
Download and install Erlang/OTP from the [official website](https://www.erlang.org/downloads). | ||
|
||
## Installing Node.js (version >= 20) | ||
|
||
Download and install Node.js and NPM from the [official website](https://nodejs.org/). | ||
|
||
## Installing Node.js Dependencies | ||
|
||
Navigate to the project directory and install the necessary dependencies: | ||
|
||
```bash | ||
yarn install | ||
``` |
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,17 @@ | ||
--- | ||
sidebar_position: 1 | ||
title: Introduction | ||
--- | ||
|
||
# Erlang and Lido Ethereum SDK Interaction | ||
|
||
## Introduction | ||
|
||
This example demonstrate the interaction between Erlang and Lido Ethereum SDK processes. The Erlang process launches a Node.js process and sends commands to retrieve a result from the Lido SDK methods. | ||
|
||
- `main.erl`: Erlang module that manages launching and interacting with the Node.js process. | ||
- `sdk.js`: Lido SDK script that processes commands received from the Erlang process and returns results. | ||
|
||
## Use Case | ||
|
||
The primary use case for this project is to integrate blockchain reward retrieval functionalities into an Erlang-based application. By leveraging the Lido SDK in a Node.js process, this project provides a way to access blockchain data and utilities that may not be easily accessible within the Erlang ecosystem. |
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,66 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Usage | ||
|
||
## Starting the Erlang Process | ||
|
||
1. Navigate to the project directory and install deps : | ||
|
||
```bash | ||
cd examples/erlang-bridge/src | ||
|
||
yarn install | ||
``` | ||
|
||
2. Replace RPC_URL in `sdk.js` with the actual RPC URL and set the `chain` parameter to which chain you want to connect: | ||
|
||
```ts | ||
const rpcProvider = createPublicClient({ | ||
chain: mainnet, | ||
transport: http('RPC_URL'), | ||
}); | ||
``` | ||
|
||
3. Start the Erlang shell: | ||
|
||
```bash | ||
rebar3 get-deps && rebar3 compile | ||
``` | ||
|
||
```bash | ||
erlc main.erl | ||
``` | ||
|
||
```bash | ||
erl -pa _build/default/lib/*/ebin | ||
``` | ||
|
||
4. In the Erlang shell, compile the `main` module: | ||
|
||
```erlang | ||
c(main). | ||
``` | ||
|
||
5. Start the Node.js process from Erlang and get the port: | ||
|
||
```erlang | ||
{ok, Port} = main:start(). | ||
``` | ||
|
||
6. Define the parameters and call the `get_rewards_from_chain` function: | ||
|
||
```erlang | ||
Params = [ | ||
{<<"address">>, <<"0x">>}, | ||
{<<"stepBlock">>, 10000}, | ||
{<<"back">>, {<<"days">>, 1}} | ||
]. | ||
Result = main:get_rewards_from_chain(Port, Params). | ||
``` | ||
|
||
- address: Ethereum address for which to retrieve rewards. | ||
- stepBlock: Max blocks in 1 query - depend on the RPC capabilities and pricing plans | ||
- back.days: Number of days to step back. |
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 @@ | ||
{ | ||
"label": "Get Started", | ||
"position": 2, | ||
"link": { | ||
"type": "generated-index" | ||
} | ||
} |
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,89 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
# Batch Requests | ||
|
||
The server also supports batch requests, allowing multiple JSON-RPC calls to be sent in a single HTTP request. Each request in the batch will be processed independently, and a single response containing the results of all requests will be returned. Note that the order of responses in the batch response may not match the order of the requests. You should match responses to requests using the `id` field. | ||
|
||
## Example Batch JSON-RPC Request | ||
|
||
```json | ||
[ | ||
{ | ||
"jsonrpc": "2.0", | ||
"method": "shares.balance", | ||
"params": ["0x2f0EA53F92252167d658963f334a91de0824e322"], | ||
"id": 1 | ||
}, | ||
{ | ||
"jsonrpc": "2.0", | ||
"method": "unsteth.getNFTsByAccount", | ||
"params": ["0x2f0EA53F92252167d658963f334a91de0824e322"], | ||
"id": 2 | ||
}, | ||
{ | ||
"jsonrpc": "2.0", | ||
"method": "events.stethEvents.getLastRebaseEvent", | ||
"params": [], | ||
"id": 3 | ||
} | ||
] | ||
``` | ||
|
||
## Example Batch Response | ||
|
||
```json | ||
[ | ||
{ | ||
"jsonrpc": "2.0", | ||
"result": [ | ||
{ | ||
"amountOfStETH": "10000000000000000", | ||
"amountOfShares": "9995810557743733", | ||
"owner": "0x", | ||
"timestamp": "16973450812", | ||
"isFinalized": true, | ||
"isClaimed": false, | ||
"id": "777" | ||
} | ||
], | ||
"id": 2 | ||
}, | ||
{ | ||
"jsonrpc": "2.0", | ||
"result": "14066156191713469572", | ||
"id": 1 | ||
}, | ||
{ | ||
"jsonrpc": "2.0", | ||
"result": { | ||
"eventName": "TokenRebased", | ||
"args": { | ||
"reportTimestamp": "1721072820", | ||
"timeElapsed": "4608", | ||
"preTotalShares": "1079179109989045486885777", | ||
"preTotalEther": "1093196098970760843229455", | ||
"postTotalShares": "1079179369664131812438396", | ||
"postTotalEther": "1093198738453702928397482", | ||
"sharesMintedAsFees": "260563376065765428" | ||
}, | ||
"address": "0x3f1c547b21f65e10480de3ad8e19faac46c95034", | ||
"topics": [ | ||
"0xff08c3ef606d198e316ef5b822193c489965899eb4e3c248cea1a4626c3eda50", | ||
"0x0000000000000000000000000000000000000000000000000000000066957cb4" | ||
], | ||
"data": "0x000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000e4866ab1ef0fa0ba1b9100000000000000000000000000000000000000000000e77e477e6cbd9ce5f90f00000000000000000000000000000000000000000000e4866e4c7c2d1e2e317c00000000000000000000000000000000000000000000e77e6c1fc07dee9674aa000000000000000000000000000000000000000000000000039db5028fe06034", | ||
"blockNumber": "1934791", | ||
"transactionHash": "0x826b3e20a499dfb655828829ba08cab037b81873237397502159ea41f9186246", | ||
"transactionIndex": 16, | ||
"blockHash": "0x61ea6638b24ef3b0215556e67bb847e44f52c97e9f24b898452b3b6c426ee82e", | ||
"logIndex": 43, | ||
"removed": false | ||
}, | ||
"id": 3 | ||
} | ||
] | ||
``` | ||
|
||
Batch requests are useful for optimizing network usage and reducing latency by sending multiple requests at once. |
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,31 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
|
||
# Handling Errors | ||
|
||
The server includes comprehensive error handling. Errors are returned in the standard JSON-RPC format, including an error code and message. | ||
|
||
## Example Error Response | ||
|
||
```json | ||
{ | ||
"jsonrpc": "2.0", | ||
"error": { | ||
"code": -32600, | ||
"message": "Invalid Request" | ||
}, | ||
"id": null | ||
} | ||
``` | ||
|
||
## Error Codes | ||
|
||
The following error codes are used by the server: | ||
|
||
- `-32600`: Invalid Request | ||
- `-32700`: Parse error | ||
- `-32601`: Method not found | ||
- `-32602`: Invalid params | ||
- `-32603`: Internal error | ||
- `-32000`: Server error |
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,32 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Installation | ||
|
||
To get started, clone the repository and install the dependencies: | ||
|
||
```bash | ||
git clone https://github.com/lidofinance/lido-ethereum-sdk.git | ||
cd packages/lido-pulse | ||
cp .env.example .env | ||
yarn install | ||
``` | ||
|
||
Fill in the `.env` file with the required environment variables. | ||
|
||
## Running the Server | ||
|
||
To start the Fastify server, run: | ||
|
||
```bash | ||
yarn start | ||
``` | ||
|
||
You can also run the server in development mode with hot reloading: | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
The server will start on port 3000 by default. |
Oops, something went wrong.