Skip to content

Commit 895cb5b

Browse files
committed
fix: return rpc url
1 parent 27d08fb commit 895cb5b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

docs/sdk/get-started/usage.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ const sdk = new LidoSDK({
5656
});
5757
```
5858

59+
or let the SDK create it for you by passing RPC URL(s):
60+
61+
```ts
62+
import { LidoSDK } from '@lidofinance/lido-ethereum-sdk';
63+
// viem is still required as peer dependency for inner workings of SDK
64+
import { hoodi } from 'viem/chains';
65+
66+
const sdk = new LidoSDK({
67+
// in this chainId must be provided explicitly
68+
chainId: hoodi.id,
69+
// multiple RPC URLs are supported and used in viem's fallback transport
70+
rpcUrls: ['<RPC_URL>'],
71+
});
72+
```
73+
5974
Replace `<RPC_URL>` with the address of your Ethereum provider.
6075

6176
## With walletClient

packages/sdk/src/core/core.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export default class LidoSDKCore extends LidoSDKCacheable {
125125

126126
publicClient: publicClientProp,
127127
walletClient: walletClientProp,
128-
// eslint-disable-next-line deprecation/deprecation
129128
rpcUrls,
130129
// eslint-disable-next-line deprecation/deprecation
131130
rpcProvider,
@@ -157,8 +156,14 @@ export default class LidoSDKCore extends LidoSDKCacheable {
157156

158157
const publicClient: LidoSdkPublicClient =
159158
publicClientProp ??
160-
// eslint-disable-next-line deprecation/deprecation
161-
LidoSDKCore.createRpcProvider(chainId, rpcUrls as string[]);
159+
createPublicClient({
160+
batch: {
161+
multicall: true,
162+
},
163+
chain: VIEM_CHAINS[chainId],
164+
// rpcUrls are checked above
165+
transport: fallback((rpcUrls as string[]).map((url) => http(url))),
166+
});
162167

163168
if (publicClient?.chain?.id !== chainId) {
164169
throw this.error({

packages/sdk/src/core/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export type LidoSdkKeyedClient = {
5151

5252
type LidoSDKCorePropsPublicClientProps =
5353
| {
54-
/** @deprecated Use `publicClient` instead. */
5554
rpcUrls: string[];
5655
chainId: (typeof SUPPORTED_CHAINS)[number];
5756
publicClient?: undefined;

0 commit comments

Comments
 (0)