diff --git a/README.md b/README.md index 99826481..f1958fed 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ ![Lido SDK Logo](./assets/package_logo.png) -# Lido Ethereum SDK +
+

Lido Ethereum SDK

+
+ +
+ GitHub license + Downloads npm + Version npm + npm bundle size + GitHub top language + GitHub Pull Requests + GitHub open issues +
+
**Lido Ethereum SDK** is a package that provides convenient tools for interacting with Lido contracts on the Ethereum network through a software development kit (SDK). This SDK simplifies working with Lido contracts and accessing their functionality. diff --git a/packages/sdk/README.md b/packages/sdk/README.md index 18c19332..3f8f1365 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -1,4 +1,17 @@ -# Lido Ethereum SDK +
+

Lido Ethereum SDK

+
+ +
+ GitHub license + Downloads npm + Version npm + npm bundle size + GitHub top language + GitHub Pull Requests + GitHub open issues +
+
**Lido Ethereum SDK** is a package that provides convenient tools for interacting with Lido contracts on the Ethereum network through a software development kit (SDK). This SDK simplifies working with Lido contracts and accessing their functionality. diff --git a/packages/sdk/src/erc20/erc20.ts b/packages/sdk/src/erc20/erc20.ts index 16dea968..458b292d 100644 --- a/packages/sdk/src/erc20/erc20.ts +++ b/packages/sdk/src/erc20/erc20.ts @@ -19,7 +19,6 @@ import { PublicClient, WalletClient, encodeFunctionData, - getContract, } from 'viem'; import { NOOP, PERMIT_MESSAGE_TYPES } from '../common/constants.js'; import { parseValue } from '../common/utils/parse-value.js'; @@ -45,19 +44,9 @@ export abstract class AbstractLidoSDKErc20 { public abstract contractAddress(): Promise
; - @Logger('Contracts:') - @Cache(30 * 60 * 1000, ['core.chain.id', 'contractAddressWstETH']) - public async getContract(): Promise< + public abstract getContract(): Promise< GetContractReturnType - > { - const address = await this.contractAddress(); - return getContract({ - address, - abi: erc20abi, - publicClient: this.core.rpcProvider, - walletClient: this.core.web3Provider, - }); - } + >; // Balance diff --git a/packages/sdk/src/erc20/steth.ts b/packages/sdk/src/erc20/steth.ts index 61b05c68..30315d7e 100644 --- a/packages/sdk/src/erc20/steth.ts +++ b/packages/sdk/src/erc20/steth.ts @@ -1,8 +1,15 @@ -import { Address } from 'viem'; +import { + Address, + GetContractReturnType, + PublicClient, + WalletClient, + getContract as getContractViem, +} from 'viem'; import { AbstractLidoSDKErc20 } from './erc20.js'; import { Logger, Cache } from '../common/decorators/index.js'; import { LIDO_CONTRACT_NAMES } from '../common/constants.js'; import invariant from 'tiny-invariant'; +import { erc20abi } from './abi/erc20abi.js'; export class LidoSDKstETH extends AbstractLidoSDKErc20 { @Logger('Contracts:') @@ -11,4 +18,18 @@ export class LidoSDKstETH extends AbstractLidoSDKErc20 { invariant(this.core.chain, 'Chain is not defined'); return this.core.getContractAddress(LIDO_CONTRACT_NAMES.lido); } + + @Logger('Contracts:') + @Cache(30 * 60 * 1000, ['core.chain.id', 'contractAddressStETH']) + public override async getContract(): Promise< + GetContractReturnType + > { + const address = await this.contractAddress(); + return getContractViem({ + address, + abi: erc20abi, + publicClient: this.core.rpcProvider, + walletClient: this.core.web3Provider, + }); + } } diff --git a/packages/sdk/src/erc20/wsteth.ts b/packages/sdk/src/erc20/wsteth.ts index ee18174a..c108475b 100644 --- a/packages/sdk/src/erc20/wsteth.ts +++ b/packages/sdk/src/erc20/wsteth.ts @@ -1,8 +1,15 @@ -import { Address } from 'viem'; +import { + Address, + GetContractReturnType, + PublicClient, + WalletClient, + getContract as getContractViem, +} from 'viem'; import { AbstractLidoSDKErc20 } from './erc20.js'; import { Logger, Cache } from '../common/decorators/index.js'; import { LIDO_CONTRACT_NAMES } from '../common/constants.js'; import invariant from 'tiny-invariant'; +import { erc20abi } from './abi/erc20abi.js'; export class LidoSDKwstETH extends AbstractLidoSDKErc20 { @Logger('Contracts:') @@ -25,4 +32,18 @@ export class LidoSDKwstETH extends AbstractLidoSDKErc20 { verifyingContract: await this.contractAddress(), }; } + + @Logger('Contracts:') + @Cache(30 * 60 * 1000, ['core.chain.id', 'contractAddressWstETH']) + public override async getContract(): Promise< + GetContractReturnType + > { + const address = await this.contractAddress(); + return getContractViem({ + address, + abi: erc20abi, + publicClient: this.core.rpcProvider, + walletClient: this.core.web3Provider, + }); + } }