Skip to content

Commit

Permalink
Merge pull request #38 from lidofinance/feature/si-742-holesky-ethere…
Browse files Browse the repository at this point in the history
…um-sdk

Holesky support
  • Loading branch information
Jeday committed Oct 6, 2023
2 parents a3f76ee + d3dd63d commit 4c260f0
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 664 deletions.
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
env:
RPC_PROVIDER_URL_1: ${{ vars.RPC_PROVIDER_URL_1 }}
RPC_PROVIDER_URL_5: ${{ vars.RPC_PROVIDER_URL_5 }}
RPC_PROVIDER_URL_17000: ${{ vars.RPC_PROVIDER_URL_17000 }}
WALLETCONNECT_PROJECT_ID: ${{ vars.WALLETCONNECT_PROJECT_ID }}
- name: Check types
run: yarn types
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
env:
RPC_PROVIDER_URL_1: ${{ vars.RPC_PROVIDER_URL_1 }}
RPC_PROVIDER_URL_5: ${{ vars.RPC_PROVIDER_URL_5 }}
RPC_PROVIDER_URL_17000: ${{ vars.RPC_PROVIDER_URL_17000 }}
WALLETCONNECT_PROJECT_ID: ${{ vars.WALLETCONNECT_PROJECT_ID }}
BASE_PATH: ${{ steps.config_pages.outputs.base_path }}
- name: Export
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"dependencies": {
"@ethersproject/bytes": "^5.7.0",
"tiny-invariant": "^1.3.1",
"viem": "^1.10.9"
"viem": "^1.15.3"
},
"devDependencies": {
"@types/fs-extra": "^11.0.1",
Expand Down
17 changes: 15 additions & 2 deletions packages/sdk/src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { type Address } from 'viem';
import { type Address, type Chain } from 'viem';
import { goerli, mainnet, holesky } from 'viem/chains';

export enum CHAINS {
Goerli = 5,
Mainnet = 1,
Holesky = 17000,
}

export const SUPPORTED_CHAINS: CHAINS[] = [CHAINS.Goerli, CHAINS.Mainnet];
export const SUPPORTED_CHAINS: CHAINS[] = [
CHAINS.Goerli,
CHAINS.Mainnet,
CHAINS.Holesky,
];

export const SUBMIT_EXTRA_GAS_TRANSACTION_RATIO = 1.05;
export const ESTIMATE_ACCOUNT = '0x87c0e047F4e4D3e289A56a36570D4CB957A37Ef1';
Expand All @@ -15,6 +21,7 @@ export const LIDO_LOCATOR_BY_CHAIN: {
} = {
[CHAINS.Mainnet]: '0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb',
[CHAINS.Goerli]: '0x1eDf09b5023DC86737b59dE68a8130De878984f5',
[CHAINS.Holesky]: '0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8',
};

export const LIDO_TOKENS = {
Expand Down Expand Up @@ -73,3 +80,9 @@ export const PERMIT_MESSAGE_TYPES = {
],
Permit: EIP2612_TYPE,
} as const;

export const VIEM_CHAINS: { [key in CHAINS]: Chain } = {
[CHAINS.Mainnet]: mainnet,
[CHAINS.Goerli]: goerli,
[CHAINS.Holesky]: holesky,
};
4 changes: 2 additions & 2 deletions packages/sdk/src/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
maxUint256,
Hash,
} from 'viem';
import { goerli, mainnet } from 'viem/chains';
import invariant from 'tiny-invariant';
import { splitSignature } from '@ethersproject/bytes';

Expand All @@ -38,6 +37,7 @@ import {
CONTRACTS_BY_TOKENS,
LIDO_TOKENS,
PERMIT_MESSAGE_TYPES,
VIEM_CHAINS,
} from '../common/constants.js';

import { LidoLocatorAbi } from './abi/lidoLocator.js';
Expand Down Expand Up @@ -91,7 +91,7 @@ export default class LidoSDKCore {
throw new Error('rpcUrls or rpcProvider is required');
}

const chain = chainId === 1 ? mainnet : goerli;
const chain = VIEM_CHAINS[chainId];
const currentRpcProvider =
rpcProvider ?? this.createRpcProvider(chain, rpcUrls);
const currentWeb3Provider = web3Provider;
Expand Down
5 changes: 3 additions & 2 deletions playground/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# Public rpc urls
RPC_PROVIDER_URL_1 = https://rpc.ankr.com/eth
RPC_PROVIDER_URL_5 = https://rpc.ankr.com/eth_goerli
RPC_PROVIDER_URL_17000 =

# supported networks for connecting wallet
SUPPORTED_CHAINS=1,5
SUPPORTED_CHAINS=1,5,17000

# this chain uses when a wallet is not connected
DEFAULT_CHAIN=5
DEFAULT_CHAIN=17000

# WalletConnect project ID
WALLETCONNECT_PROJECT_ID=
Expand Down
9 changes: 1 addition & 8 deletions playground/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ RUN rm -rf /app/public/runtime && mkdir /app/public/runtime && chown node /app/p
# final image
FROM node:16-alpine as base

ARG BASE_PATH=""
ARG SUPPORTED_CHAINS="1"
ARG DEFAULT_CHAIN="1"

ENV NEXT_TELEMETRY_DISABLED=1 \
BASE_PATH=$BASE_PATH \
SUPPORTED_CHAINS=$SUPPORTED_CHAINS \
DEFAULT_CHAIN=$DEFAULT_CHAIN
ENV NEXT_TELEMETRY_DISABLED=1

WORKDIR /app
RUN apk add --no-cache curl=7.83.1-r4
Expand Down
1 change: 1 addition & 0 deletions playground/config/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export const getBackendRPCPath = (chainId: CHAINS) => {
export const backendRPC = {
[CHAINS.Mainnet]: getBackendRPCPath(CHAINS.Mainnet),
[CHAINS.Goerli]: getBackendRPCPath(CHAINS.Goerli),
[CHAINS.Holesky]: getBackendRPCPath(CHAINS.Holesky),
};
5 changes: 3 additions & 2 deletions playground/env-dynamics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
export const rpcProviderUrls = {
1: process.env[`RPC_PROVIDER_URL_1`],
5: process.env[`RPC_PROVIDER_URL_5`],
17000: process.env[`RPC_PROVIDER_URL_17000`],
};
/** @type number */
export const defaultChain = parseInt(process.env.DEFAULT_CHAIN, 10) || 5;
export const defaultChain = parseInt(process.env.DEFAULT_CHAIN, 10) || 17000;
/** @type number[] */
export const supportedChains = process.env?.SUPPORTED_CHAINS?.split(',').map(
(chainId) => parseInt(chainId, 10),
) ?? [1, 5];
) ?? [1, 5, 17000];
export const walletconnectProjectId = process.env.WALLETCONNECT_PROJECT_ID;
11 changes: 6 additions & 5 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/constants": "^5.5.0",
"@ethersproject/units": "^5.6.1",
"@lido-sdk/constants": "^1.6.0",
"@lido-sdk/web3-react": "^2.0.0",
"@lido-sdk/constants": "^3.2.1",
"@lido-sdk/providers": "^1.4.14",
"@lido-sdk/react": "^2.0.3",
"@lidofinance/lido-ethereum-sdk": "workspace:*",
"@lidofinance/lido-ui": "^3.10.1",
"@lidofinance/next-cache-files-middleware": "^0.35.0",
"@reef-knot/connect-wallet-modal": "1.6.2",
"@reef-knot/core-react": "1.5.1",
"@reef-knot/core-react": "1.6.0",
"@reef-knot/ledger-connector": "1.0.1",
"@reef-knot/types": "1.3.0",
"@reef-knot/ui-react": "1.0.7",
"@reef-knot/wallets-helpers": "1.1.5",
"@reef-knot/wallets-icons": "1.0.0",
"@reef-knot/wallets-list": "1.4.4",
"@reef-knot/web3-react": "1.4.2",
"@reef-knot/wallets-list": "1.4.5",
"@reef-knot/web3-react": "1.5.0",
"copy-to-clipboard": "^3.3.1",
"fs-extra": "^10.1.0",
"next": "^13.0.5",
Expand Down
8 changes: 4 additions & 4 deletions playground/providers/web3.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { FC, PropsWithChildren } from 'react';
import { ProviderWeb3 } from '@reef-knot/web3-react';
import { getConnectors } from '@reef-knot/core-react';
import { getConnectors, holesky } from '@reef-knot/core-react';
import { backendRPC, getBackendRPCPath, dynamics } from 'config';
import { WagmiConfig, createClient, configureChains, Chain } from 'wagmi';
import * as wagmiChains from 'wagmi/chains';
import { getStaticRpcBatchProvider } from '@lido-sdk/providers';

const wagmiChainsArray = Object.values(wagmiChains);
const supportedChains = wagmiChainsArray.filter(
(chain) => dynamics.supportedChains.includes(chain.id),
const wagmiChainsArray = Object.values({ ...wagmiChains, holesky });
const supportedChains = wagmiChainsArray.filter((chain) =>
dynamics.supportedChains.includes(chain.id),
);
const defaultChain = wagmiChainsArray.find(
(chain) => chain.id === dynamics.defaultChain,
Expand Down
Loading

0 comments on commit 4c260f0

Please sign in to comment.