Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra tests for l2 module #159

Merged
merged 8 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ jobs:
TEST_PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }}
TEST_CHAIN_ID: ${{ vars.TEST_CHAIN_ID }}
TEST_RPC_URL: ${{ secrets.TEST_RPC_URL }}
TEST_L2_CHAIN_ID: ${{ vars.TEST_L2_CHAIN_ID }}
TEST_L2_RPC_URL: ${{ secrets.TEST_L2_RPC_URL }}
TEST_SUBGRAPH_URL: ${{ secrets.TEST_SUBGRAPH_URL }}
30 changes: 14 additions & 16 deletions packages/sdk/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import {
holesky,
sepolia,
optimismSepolia,
optimism,
} from 'viem/chains';

export enum CHAINS {
Goerli = 5,
Mainnet = 1,
Holesky = 17000,
Sepolia = 11155111,
Optimism = 10,
OptimismSepolia = 11155420,
}

Expand All @@ -30,33 +32,28 @@ export const GAS_TRANSACTION_RATIO_PRECISION = 10 ** 7;
export const ESTIMATE_ACCOUNT = '0x87c0e047F4e4D3e289A56a36570D4CB957A37Ef1';

export const LIDO_LOCATOR_BY_CHAIN: {
[key in CHAINS]: Address | null;
[key in CHAINS]?: Address;
} = {
[CHAINS.Mainnet]: '0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb',
[CHAINS.Goerli]: '0x1eDf09b5023DC86737b59dE68a8130De878984f5',
[CHAINS.Holesky]: '0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8',
[CHAINS.Sepolia]: '0x8f6254332f69557A72b0DA2D5F0Bc07d4CA991E7',
[CHAINS.OptimismSepolia]: null,
};

export const SUBRGRAPH_ID_BY_CHAIN: {
[key in CHAINS]: string | null;
[key in CHAINS]?: string;
} = {
[CHAINS.Mainnet]: 'Sxx812XgeKyzQPaBpR5YZWmGV5fZuBaPdh7DFhzSwiQ',
[CHAINS.Goerli]: 'QmeDfGTuNbSoZ71zi3Ch4WNRbzALfiFPnJMYUFPinLiFNa',
[CHAINS.Holesky]: null,
[CHAINS.Sepolia]: null,
[CHAINS.OptimismSepolia]: null,
};

export const EARLIEST_TOKEN_REBASED_EVENT: {
[key in CHAINS]: bigint;
[key in CHAINS]?: bigint;
} = {
[CHAINS.Mainnet]: 17272708n,
[CHAINS.Goerli]: 8712039n,
[CHAINS.Holesky]: 52174n,
[CHAINS.Sepolia]: 5434668n,
[CHAINS.OptimismSepolia]: 0n,
} as const;

export const LIDO_TOKENS = {
Expand Down Expand Up @@ -89,15 +86,17 @@ export const enum LIDO_L2_CONTRACT_NAMES {
steth = 'steth',
}

export const LIDO_L2_CONTRACT_ADDRESSES: Record<
number,
Record<LIDO_L2_CONTRACT_NAMES, Address>
> = {
export const LIDO_L2_CONTRACT_ADDRESSES: {
[key in CHAINS]?: { [key2 in LIDO_L2_CONTRACT_NAMES]?: Address };
} = {
[CHAINS.OptimismSepolia]: {
wsteth: '0x24B47cd3A74f1799b32B2de11073764Cb1bb318B',
steth: '0xf49d208b5c7b10415c7beafe9e656f2df9edfe3b',
},
} as const;
[CHAINS.Optimism]: {
wsteth: '0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb',
},
};

export const CONTRACTS_BY_TOKENS = {
[LIDO_TOKENS.steth]: LIDO_CONTRACT_NAMES.lido,
Expand Down Expand Up @@ -136,13 +135,12 @@ export const VIEM_CHAINS: { [key in CHAINS]: Chain } = {
[CHAINS.Goerli]: goerli,
[CHAINS.Holesky]: holesky,
[CHAINS.Sepolia]: sepolia,
[CHAINS.Optimism]: optimism,
[CHAINS.OptimismSepolia]: optimismSepolia,
};

export const WQ_API_URLS: { [key in CHAINS]: string | null } = {
export const WQ_API_URLS: { [key in CHAINS]?: string } = {
[CHAINS.Mainnet]: 'https://wq-api.lido.fi',
[CHAINS.Goerli]: 'https://wq-api.testnet.fi',
[CHAINS.Holesky]: 'https://wq-api-holesky.testnet.fi',
[CHAINS.Sepolia]: null,
[CHAINS.OptimismSepolia]: null,
};
4 changes: 2 additions & 2 deletions packages/sdk/src/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export default class LidoSDKCore extends LidoSDKCacheable {
@Logger('Utils:')
@Cache(30 * 60 * 1000, ['chain.id'])
public getL2ContractAddress(contract: LIDO_L2_CONTRACT_NAMES): Address {
const chainConfig = LIDO_L2_CONTRACT_ADDRESSES[this.chain.id];
const chainConfig = LIDO_L2_CONTRACT_ADDRESSES[this.chain.id as CHAINS];
invariant(
chainConfig,
`Lido L2 contracts are not supported for ${this.chain.name}(${this.chain.id})`,
Expand All @@ -408,7 +408,7 @@ export default class LidoSDKCore extends LidoSDKCacheable {
@Logger('Utils:')
@Cache(30 * 60 * 1000, ['chain.id'])
public getSubgraphId(): string | null {
const id = SUBRGRAPH_ID_BY_CHAIN[this.chainId];
const id = SUBRGRAPH_ID_BY_CHAIN[this.chainId] ?? null;
return id;
}

Expand Down
Loading