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

1533: Add new handlers and add support for depositing stETH and wstETH #14

Merged
merged 9 commits into from
Jun 17, 2024
4 changes: 2 additions & 2 deletions lib/api/puffer-client-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Chain } from '../chains/constants';
describe('PufferClientHelpers', () => {
it('should create public client with defined config', () => {
const publicClient = PufferClientHelpers.createPublicClient({
chain: Chain.Anvil,
chain: Chain.Holesky,
rpcUrls: ['rpcUrl'],
});

Expand All @@ -14,7 +14,7 @@ describe('PufferClientHelpers', () => {

it('should create wallet client with defined config', () => {
const walletClient = PufferClientHelpers.createWalletClient({
chain: Chain.Anvil,
chain: Chain.Holesky,
provider: { request: jest.fn() },
});

Expand Down
4 changes: 2 additions & 2 deletions lib/api/puffer-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('PufferClient', () => {
});
const walletClient = setupMockWalletClient(walletRequest);

const pufferClient = new PufferClient(Chain.Anvil, walletClient);
const pufferClient = new PufferClient(Chain.Holesky, walletClient);
const [address] = await pufferClient.requestAddresses();

expect(address).toBe(mockAddress);
Expand All @@ -34,7 +34,7 @@ describe('PufferClient', () => {
const publicClient = setupMockPublicClient(publicRequest);

const pufferClient = new PufferClient(
Chain.Anvil,
Chain.Holesky,
walletClient,
publicClient,
);
Expand Down
10 changes: 10 additions & 0 deletions lib/api/puffer-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from 'viem';
import { Chain, VIEM_CHAINS } from '../chains/constants';
import { PufferVaultHandler } from '../contracts/handlers/puffer-vault-handler';
import { PufferDepositorHandler } from '../contracts/handlers/puffer-depositor-handler';

/**
* The core class and the main entry point of the Puffer SDK.
Expand All @@ -16,7 +17,10 @@ export class PufferClient {
private publicClient: PublicClient;

// Contract Handlers
/** Handler for the `PufferVaultV2` contract. */
public vault: PufferVaultHandler;
/** Handler for the `PufferDepositor` contract. */
public depositor: PufferDepositorHandler;

/**
* Create the Puffer Client.
Expand Down Expand Up @@ -52,6 +56,12 @@ export class PufferClient {
this.walletClient,
this.publicClient,
);

this.depositor = new PufferDepositorHandler(
chain,
this.walletClient,
this.publicClient,
);
}

/**
Expand Down
8 changes: 3 additions & 5 deletions lib/chains/constants.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Chain as ViemChain } from 'viem';
import { mainnet, anvil, holesky } from 'viem/chains';
import { mainnet, holesky } from 'viem/chains';

export enum Chain {
Mainnet = 'mainnet',
Holesky = 'holesky',
Anvil = 'anvil',
Mainnet = mainnet.id,
Holesky = holesky.id,
}

export const VIEM_CHAINS: { [key in Chain]: ViemChain } = {
[Chain.Mainnet]: mainnet,
[Chain.Holesky]: holesky,
[Chain.Anvil]: anvil,
};

export { type ViemChain };
Loading
Loading