Skip to content

Commit 255e3a2

Browse files
authored
Merge pull request #147 from lidofinance/develop
Develop to main
2 parents 87ec66c + 1a7ac9d commit 255e3a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2265
-8
lines changed

.github/workflows/publish-alpha.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ permissions:
88
id-token: write # to enable use of OIDC for npm provenance
99

1010
jobs:
11+
pre-publish:
12+
if: github.ref == 'refs/heads/develop'
13+
uses: ./.github/workflows/publish-dry-run.yml
14+
secrets:
15+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1116
publish:
17+
needs: pre-publish
1218
runs-on: ubuntu-latest
1319
environment: development
1420
# restricts job to develop branch
@@ -44,7 +50,7 @@ jobs:
4450
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4551

4652
- name: Publish Alpha
47-
run: yarn multi-semantic-release --deps.bump=override --deps.release=patch --sequential-init
53+
run: yarn multi-semantic-release
4854
env:
4955
NPM_CONFIG_PROVENANCE: true
5056
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-dry-run.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish Dry Run
2+
on:
3+
workflow_dispatch:
4+
workflow_call:
5+
secrets:
6+
NPM_TOKEN:
7+
description: 'NPM token'
8+
required: true
9+
10+
jobs:
11+
publish-dry-run:
12+
runs-on: ubuntu-latest
13+
environment: development
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
persist-credentials: false
20+
21+
- name: Setup Node
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: 'yarn'
26+
27+
- name: Install dependencies
28+
run: yarn --immutable
29+
30+
- name: Build
31+
run: yarn build:packages
32+
33+
- name: Dry run Publish
34+
run: yarn multi-semantic-release --dry-run --silent | grep -E '#|###|\*' > dry_run_output.txt
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
39+
- name: Write results to summary
40+
run: |
41+
if [ -s dry_run_output.txt ]; then
42+
echo "# Packages to be published:" >> $GITHUB_STEP_SUMMARY
43+
cat dry_run_output.txt >> $GITHUB_STEP_SUMMARY
44+
else
45+
echo "Nothing will be published" >> $GITHUB_STEP_SUMMARY
46+
fi

.github/workflows/publish.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ permissions:
1010
id-token: write # to enable use of OIDC for npm provenance
1111

1212
jobs:
13+
pre-publish:
14+
uses: ./.github/workflows/publish-dry-run.yml
15+
secrets:
16+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1317
publish:
18+
needs: pre-publish
1419
runs-on: ubuntu-latest
1520
environment: production
1621
steps:
@@ -44,7 +49,7 @@ jobs:
4449
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4550

4651
- name: Publish
47-
run: yarn multi-semantic-release --deps.bump=override --deps.release=patch --sequential-init
52+
run: yarn multi-semantic-release
4853
env:
4954
NPM_CONFIG_PROVENANCE: true
5055
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/docusaurus.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ const config: Config = {
3232
sidebarPath: './sidebarsExamples.ts',
3333
},
3434
],
35+
[
36+
'@docusaurus/plugin-content-docs',
37+
{
38+
id: 'lidoPulse',
39+
path: 'lidoPulse',
40+
routeBasePath: 'lidoPulse',
41+
sidebarPath: './sidebarsLidoPulse.ts',
42+
},
43+
],
3544
],
3645
presets: [
3746
[
@@ -74,6 +83,7 @@ const config: Config = {
7483
label: 'Docs',
7584
},
7685
{ to: '/examples/intro', label: 'Examples', position: 'left' },
86+
{ to: '/lidoPulse/intro', label: 'LidoPulse', position: 'left' },
7787
{
7888
href: '/playground',
7989
label: 'Playground',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "Erlang Bridge",
3+
"position": 3,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Installation
6+
7+
## Installing Erlang
8+
9+
Download and install Erlang/OTP from the [official website](https://www.erlang.org/downloads).
10+
11+
## Installing Node.js (version >= 20)
12+
13+
Download and install Node.js and NPM from the [official website](https://nodejs.org/).
14+
15+
## Installing Node.js Dependencies
16+
17+
Navigate to the project directory and install the necessary dependencies:
18+
19+
```bash
20+
yarn install
21+
```

docs/examples/erlang-bridge/intro.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
sidebar_position: 1
3+
title: Introduction
4+
---
5+
6+
# Erlang and Lido Ethereum SDK Interaction
7+
8+
## Introduction
9+
10+
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.
11+
12+
- `main.erl`: Erlang module that manages launching and interacting with the Node.js process.
13+
- `sdk.js`: Lido SDK script that processes commands received from the Erlang process and returns results.
14+
15+
## Use Case
16+
17+
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.

docs/examples/erlang-bridge/usage.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
# Usage
6+
7+
## Starting the Erlang Process
8+
9+
1. Navigate to the project directory and install deps :
10+
11+
```bash
12+
cd examples/erlang-bridge/src
13+
14+
yarn install
15+
```
16+
17+
2. Replace RPC_URL in `sdk.js` with the actual RPC URL and set the `chain` parameter to which chain you want to connect:
18+
19+
```ts
20+
const rpcProvider = createPublicClient({
21+
chain: mainnet,
22+
transport: http('RPC_URL'),
23+
});
24+
```
25+
26+
3. Start the Erlang shell:
27+
28+
```bash
29+
rebar3 get-deps && rebar3 compile
30+
```
31+
32+
```bash
33+
erlc main.erl
34+
```
35+
36+
```bash
37+
erl -pa _build/default/lib/*/ebin
38+
```
39+
40+
4. In the Erlang shell, compile the `main` module:
41+
42+
```erlang
43+
c(main).
44+
```
45+
46+
5. Start the Node.js process from Erlang and get the port:
47+
48+
```erlang
49+
{ok, Port} = main:start().
50+
```
51+
52+
6. Define the parameters and call the `get_rewards_from_chain` function:
53+
54+
```erlang
55+
Params = [
56+
{<<"address">>, <<"0x">>},
57+
{<<"stepBlock">>, 10000},
58+
{<<"back">>, {<<"days">>, 1}}
59+
].
60+
61+
Result = main:get_rewards_from_chain(Port, Params).
62+
```
63+
64+
- address: Ethereum address for which to retrieve rewards.
65+
- stepBlock: Max blocks in 1 query - depend on the RPC capabilities and pricing plans
66+
- back.days: Number of days to step back.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "Get Started",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
# Batch Requests
6+
7+
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.
8+
9+
## Example Batch JSON-RPC Request
10+
11+
```json
12+
[
13+
{
14+
"jsonrpc": "2.0",
15+
"method": "shares.balance",
16+
"params": ["0x2f0EA53F92252167d658963f334a91de0824e322"],
17+
"id": 1
18+
},
19+
{
20+
"jsonrpc": "2.0",
21+
"method": "unsteth.getNFTsByAccount",
22+
"params": ["0x2f0EA53F92252167d658963f334a91de0824e322"],
23+
"id": 2
24+
},
25+
{
26+
"jsonrpc": "2.0",
27+
"method": "events.stethEvents.getLastRebaseEvent",
28+
"params": [],
29+
"id": 3
30+
}
31+
]
32+
```
33+
34+
## Example Batch Response
35+
36+
```json
37+
[
38+
{
39+
"jsonrpc": "2.0",
40+
"result": [
41+
{
42+
"amountOfStETH": "10000000000000000",
43+
"amountOfShares": "9995810557743733",
44+
"owner": "0x",
45+
"timestamp": "16973450812",
46+
"isFinalized": true,
47+
"isClaimed": false,
48+
"id": "777"
49+
}
50+
],
51+
"id": 2
52+
},
53+
{
54+
"jsonrpc": "2.0",
55+
"result": "14066156191713469572",
56+
"id": 1
57+
},
58+
{
59+
"jsonrpc": "2.0",
60+
"result": {
61+
"eventName": "TokenRebased",
62+
"args": {
63+
"reportTimestamp": "1721072820",
64+
"timeElapsed": "4608",
65+
"preTotalShares": "1079179109989045486885777",
66+
"preTotalEther": "1093196098970760843229455",
67+
"postTotalShares": "1079179369664131812438396",
68+
"postTotalEther": "1093198738453702928397482",
69+
"sharesMintedAsFees": "260563376065765428"
70+
},
71+
"address": "0x3f1c547b21f65e10480de3ad8e19faac46c95034",
72+
"topics": [
73+
"0xff08c3ef606d198e316ef5b822193c489965899eb4e3c248cea1a4626c3eda50",
74+
"0x0000000000000000000000000000000000000000000000000000000066957cb4"
75+
],
76+
"data": "0x000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000e4866ab1ef0fa0ba1b9100000000000000000000000000000000000000000000e77e477e6cbd9ce5f90f00000000000000000000000000000000000000000000e4866e4c7c2d1e2e317c00000000000000000000000000000000000000000000e77e6c1fc07dee9674aa000000000000000000000000000000000000000000000000039db5028fe06034",
77+
"blockNumber": "1934791",
78+
"transactionHash": "0x826b3e20a499dfb655828829ba08cab037b81873237397502159ea41f9186246",
79+
"transactionIndex": 16,
80+
"blockHash": "0x61ea6638b24ef3b0215556e67bb847e44f52c97e9f24b898452b3b6c426ee82e",
81+
"logIndex": 43,
82+
"removed": false
83+
},
84+
"id": 3
85+
}
86+
]
87+
```
88+
89+
Batch requests are useful for optimizing network usage and reducing latency by sending multiple requests at once.

docs/lidoPulse/get-started/errors.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
sidebar_position: 5
3+
---
4+
5+
# Handling Errors
6+
7+
The server includes comprehensive error handling. Errors are returned in the standard JSON-RPC format, including an error code and message.
8+
9+
## Example Error Response
10+
11+
```json
12+
{
13+
"jsonrpc": "2.0",
14+
"error": {
15+
"code": -32600,
16+
"message": "Invalid Request"
17+
},
18+
"id": null
19+
}
20+
```
21+
22+
## Error Codes
23+
24+
The following error codes are used by the server:
25+
26+
- `-32600`: Invalid Request
27+
- `-32700`: Parse error
28+
- `-32601`: Method not found
29+
- `-32602`: Invalid params
30+
- `-32603`: Internal error
31+
- `-32000`: Server error
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Installation
6+
7+
To get started, clone the repository and install the dependencies:
8+
9+
```bash
10+
git clone https://github.com/lidofinance/lido-ethereum-sdk.git
11+
cd packages/lido-pulse
12+
cp .env.example .env
13+
yarn install
14+
```
15+
16+
Fill in the `.env` file with the required environment variables.
17+
18+
## Running the Server
19+
20+
To start the Fastify server, run:
21+
22+
```bash
23+
yarn start
24+
```
25+
26+
You can also run the server in development mode with hot reloading:
27+
28+
```bash
29+
yarn dev
30+
```
31+
32+
The server will start on port 3000 by default.

0 commit comments

Comments
 (0)