@obolnetwork/obol-sdk 2.10.1 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/cjs/src/abi/BatchDeposit.js +120 -0
  4. package/dist/cjs/src/abi/Multicall3.js +253 -0
  5. package/dist/cjs/src/bytecodes.js +4 -4
  6. package/dist/cjs/src/constants.js +14 -7
  7. package/dist/cjs/src/eoa/eoa.js +48 -0
  8. package/dist/cjs/src/eoa/eoaHelpers.js +45 -1
  9. package/dist/cjs/src/index.js +2 -2
  10. package/dist/cjs/src/schema.js +83 -1
  11. package/dist/cjs/src/splits/splitHelpers.js +64 -19
  12. package/dist/cjs/src/splits/splits.js +54 -11
  13. package/dist/cjs/test/eoa/eoa.spec.js +75 -0
  14. package/dist/cjs/test/splits/splits.spec.js +84 -0
  15. package/dist/esm/package.json +1 -1
  16. package/dist/esm/src/abi/BatchDeposit.js +117 -0
  17. package/dist/esm/src/abi/Multicall3.js +250 -0
  18. package/dist/esm/src/bytecodes.js +3 -3
  19. package/dist/esm/src/constants.js +15 -8
  20. package/dist/esm/src/eoa/eoa.js +50 -2
  21. package/dist/esm/src/eoa/eoaHelpers.js +43 -0
  22. package/dist/esm/src/index.js +2 -2
  23. package/dist/esm/src/schema.js +82 -0
  24. package/dist/esm/src/splits/splitHelpers.js +61 -17
  25. package/dist/esm/src/splits/splits.js +56 -13
  26. package/dist/esm/test/eoa/eoa.spec.js +76 -1
  27. package/dist/esm/test/splits/splits.spec.js +85 -1
  28. package/dist/types/src/abi/BatchDeposit.d.ts +49 -0
  29. package/dist/types/src/abi/Multicall3.d.ts +37 -0
  30. package/dist/types/src/bytecodes.d.ts +3 -3
  31. package/dist/types/src/eoa/eoa.d.ts +34 -1
  32. package/dist/types/src/eoa/eoaHelpers.d.ts +15 -0
  33. package/dist/types/src/schema.d.ts +76 -0
  34. package/dist/types/src/splits/splitHelpers.d.ts +22 -1
  35. package/dist/types/src/splits/splits.d.ts +33 -1
  36. package/dist/types/src/types.d.ts +40 -1
  37. package/package.json +1 -1
  38. package/src/abi/BatchDeposit.ts +117 -0
  39. package/src/abi/Multicall3.ts +250 -0
  40. package/src/bytecodes.ts +3 -3
  41. package/src/constants.ts +17 -10
  42. package/src/eoa/eoa.ts +60 -2
  43. package/src/eoa/eoaHelpers.ts +68 -0
  44. package/src/index.ts +4 -4
  45. package/src/schema.ts +84 -0
  46. package/src/splits/splitHelpers.ts +99 -19
  47. package/src/splits/splits.ts +65 -15
  48. package/src/types.ts +43 -1
  49. package/dist/cjs/src/abi/Multicall.js +0 -148
  50. package/dist/esm/src/abi/Multicall.js +0 -145
  51. package/dist/types/src/abi/Multicall.d.ts +0 -35
  52. package/src/abi/Multicall.ts +0 -145
@@ -8,10 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { EOA } from '../../src/eoa/eoa';
11
- import { submitEOAWithdrawalRequest } from '../../src/eoa/eoaHelpers';
11
+ import { submitEOAWithdrawalRequest, submitEOABatchDeposit, } from '../../src/eoa/eoaHelpers';
12
12
  // Mock the helper function
13
13
  jest.mock('../../src/eoa/eoaHelpers', () => ({
14
14
  submitEOAWithdrawalRequest: jest.fn(),
15
+ submitEOABatchDeposit: jest.fn(),
15
16
  }));
16
17
  describe('EOA', () => {
17
18
  let eoa;
@@ -93,4 +94,78 @@ describe('EOA', () => {
93
94
  expect(result).toEqual(mockResult);
94
95
  }));
95
96
  });
97
+ describe('deposit', () => {
98
+ const mockDeposits = [
99
+ {
100
+ pubKey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
101
+ withdrawalCredentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
102
+ signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
103
+ amount: '32000000000000000000', // 32 ETH in wei
104
+ },
105
+ ];
106
+ it('should successfully deposit to batch contract', () => __awaiter(void 0, void 0, void 0, function* () {
107
+ const mockPayload = {
108
+ deposits: mockDeposits,
109
+ };
110
+ const mockResult = {
111
+ txHashes: [
112
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
113
+ ],
114
+ };
115
+ submitEOABatchDeposit.mockResolvedValue(mockResult);
116
+ const result = yield eoa.deposit(mockPayload);
117
+ expect(submitEOABatchDeposit).toHaveBeenCalledWith({
118
+ deposits: mockDeposits,
119
+ batchDepositContractAddress: '0xcD7a6C118Ac8F6544BC5076F2D8Fb86D2C546756',
120
+ signer: mockSigner,
121
+ });
122
+ expect(result).toEqual(mockResult);
123
+ }));
124
+ it('should throw error when signer is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
125
+ const eoaWithoutSigner = new EOA(undefined, 1, mockProvider);
126
+ const mockPayload = {
127
+ deposits: mockDeposits,
128
+ };
129
+ yield expect(eoaWithoutSigner.deposit(mockPayload)).rejects.toThrow('Signer is required in deposit');
130
+ }));
131
+ it('should throw error when batch deposit contract is not configured for chain', () => __awaiter(void 0, void 0, void 0, function* () {
132
+ const eoaUnsupportedChain = new EOA(mockSigner, 999, mockProvider);
133
+ const mockPayload = {
134
+ deposits: mockDeposits,
135
+ };
136
+ yield expect(eoaUnsupportedChain.deposit(mockPayload)).rejects.toThrow('Batch deposit contract is not configured for chain 999');
137
+ }));
138
+ it('should handle multiple deposits', () => __awaiter(void 0, void 0, void 0, function* () {
139
+ const multipleDeposits = [
140
+ {
141
+ pubKey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
142
+ withdrawalCredentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
143
+ signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
144
+ amount: '32000000000000000000',
145
+ },
146
+ {
147
+ pubKey: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdcd',
148
+ withdrawalCredentials: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
149
+ signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
150
+ amount: '16000000000000000000',
151
+ },
152
+ ];
153
+ const mockPayload = {
154
+ deposits: multipleDeposits,
155
+ };
156
+ const mockResult = {
157
+ txHashes: [
158
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
159
+ ],
160
+ };
161
+ submitEOABatchDeposit.mockResolvedValue(mockResult);
162
+ const result = yield eoa.deposit(mockPayload);
163
+ expect(submitEOABatchDeposit).toHaveBeenCalledWith({
164
+ deposits: multipleDeposits,
165
+ batchDepositContractAddress: '0xcD7a6C118Ac8F6544BC5076F2D8Fb86D2C546756',
166
+ signer: mockSigner,
167
+ });
168
+ expect(result).toEqual(mockResult);
169
+ }));
170
+ });
96
171
  });
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { Client } from '../../src';
11
11
  import { CHAIN_CONFIGURATION } from '../../src/constants';
12
- import { formatRecipientsForSplitV2, predictSplitV2Address, isSplitV2Deployed, deployOVMAndSplitV2, deployOVMContract, requestWithdrawalFromOVM, } from '../../src/splits/splitHelpers';
12
+ import { formatRecipientsForSplitV2, predictSplitV2Address, isSplitV2Deployed, deployOVMAndSplitV2, deployOVMContract, requestWithdrawalFromOVM, depositWithMulticall3, } from '../../src/splits/splitHelpers';
13
13
  import { isContractAvailable } from '../../src/utils';
14
14
  import { TEST_ADDRESSES } from '../fixtures';
15
15
  // Mock the split helpers
@@ -20,6 +20,7 @@ jest.mock('../../src/splits/splitHelpers', () => ({
20
20
  deployOVMContract: jest.fn(),
21
21
  deployOVMAndSplitV2: jest.fn(),
22
22
  requestWithdrawalFromOVM: jest.fn(),
23
+ depositWithMulticall3: jest.fn(),
23
24
  }));
24
25
  // Mock the utils
25
26
  jest.mock('../../src/utils', () => ({
@@ -36,6 +37,7 @@ const mockIsSplitV2Deployed = isSplitV2Deployed;
36
37
  const mockDeployOVMAndSplitV2 = deployOVMAndSplitV2;
37
38
  const mockDeployOVMContract = deployOVMContract;
38
39
  const mockRequestWithdrawalFromOVM = requestWithdrawalFromOVM;
40
+ const mockdepositWithMulticall3 = depositWithMulticall3;
39
41
  const mockIsContractAvailable = isContractAvailable;
40
42
  describe('ObolSplits', () => {
41
43
  let client;
@@ -305,6 +307,88 @@ describe('ObolSplits', () => {
305
307
  });
306
308
  }));
307
309
  });
310
+ describe('deposit', () => {
311
+ const mockOVMAddress = '0x1234567890123456789012345678901234567890';
312
+ const mockDeposits = [
313
+ {
314
+ pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
315
+ withdrawal_credentials: '0x1234567890123456789012345678901234567890',
316
+ signature: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
317
+ deposit_data_root: '0x1234567890123456789012345678901234567890123456789012345678901234',
318
+ amount: '32000000000000000000', // 32 ETH in wei
319
+ },
320
+ ];
321
+ beforeEach(() => {
322
+ mockdepositWithMulticall3.mockReset();
323
+ });
324
+ it('should successfully deposit to OVM with multicall3', () => __awaiter(void 0, void 0, void 0, function* () {
325
+ mockdepositWithMulticall3.mockResolvedValue({
326
+ txHashes: [
327
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
328
+ ],
329
+ });
330
+ const result = yield client.splits.deposit({
331
+ ovmAddress: mockOVMAddress,
332
+ deposits: mockDeposits,
333
+ });
334
+ expect(result).toEqual({
335
+ txHashes: [
336
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
337
+ ],
338
+ });
339
+ expect(mockdepositWithMulticall3).toHaveBeenCalledWith({
340
+ ovmAddress: mockOVMAddress,
341
+ deposits: mockDeposits,
342
+ signer: mockSigner,
343
+ chainId: 1,
344
+ });
345
+ }));
346
+ it('should throw error when signer is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
347
+ const clientWithoutSigner = new Client({ chainId: 1 }, undefined, mockProvider);
348
+ yield expect(clientWithoutSigner.splits.deposit({
349
+ ovmAddress: mockOVMAddress,
350
+ deposits: mockDeposits,
351
+ })).rejects.toThrow('Signer is required in deposit');
352
+ }));
353
+ it('should handle multiple deposits', () => __awaiter(void 0, void 0, void 0, function* () {
354
+ const multipleDeposits = [
355
+ {
356
+ pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
357
+ withdrawal_credentials: '0x1234567890123456789012345678901234567890',
358
+ signature: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
359
+ deposit_data_root: '0x1234567890123456789012345678901234567890123456789012345678901234',
360
+ amount: '32000000000000000000', // 32 ETH in wei
361
+ },
362
+ {
363
+ pubkey: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
364
+ withdrawal_credentials: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
365
+ signature: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
366
+ deposit_data_root: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
367
+ amount: '16000000000000000000', // 16 ETH in wei
368
+ },
369
+ ];
370
+ mockdepositWithMulticall3.mockResolvedValue({
371
+ txHashes: [
372
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
373
+ ],
374
+ });
375
+ const result = yield client.splits.deposit({
376
+ ovmAddress: mockOVMAddress,
377
+ deposits: multipleDeposits,
378
+ });
379
+ expect(result).toEqual({
380
+ txHashes: [
381
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
382
+ ],
383
+ });
384
+ expect(mockdepositWithMulticall3).toHaveBeenCalledWith({
385
+ ovmAddress: mockOVMAddress,
386
+ deposits: multipleDeposits,
387
+ signer: mockSigner,
388
+ chainId: 1,
389
+ });
390
+ }));
391
+ });
308
392
  describe('constructor', () => {
309
393
  it('should create Client instance with splits property', () => {
310
394
  const testClient = new Client({ chainId: 1 }, mockSigner, mockProvider);
@@ -0,0 +1,49 @@
1
+ export declare const BatchDepositContract: {
2
+ abi: ({
3
+ inputs: never[];
4
+ name: string;
5
+ type: string;
6
+ anonymous?: undefined;
7
+ outputs?: undefined;
8
+ stateMutability?: undefined;
9
+ } | {
10
+ anonymous: boolean;
11
+ inputs: {
12
+ indexed: boolean;
13
+ internalType: string;
14
+ name: string;
15
+ type: string;
16
+ }[];
17
+ name: string;
18
+ type: string;
19
+ outputs?: undefined;
20
+ stateMutability?: undefined;
21
+ } | {
22
+ inputs: {
23
+ components: {
24
+ internalType: string;
25
+ name: string;
26
+ type: string;
27
+ }[];
28
+ internalType: string;
29
+ name: string;
30
+ type: string;
31
+ }[];
32
+ name: string;
33
+ outputs: never[];
34
+ stateMutability: string;
35
+ type: string;
36
+ anonymous?: undefined;
37
+ } | {
38
+ inputs: never[];
39
+ name: string;
40
+ outputs: {
41
+ internalType: string;
42
+ name: string;
43
+ type: string;
44
+ }[];
45
+ stateMutability: string;
46
+ type: string;
47
+ anonymous?: undefined;
48
+ })[];
49
+ };
@@ -0,0 +1,37 @@
1
+ export declare const MultiCall3Contract: {
2
+ abi: {
3
+ inputs: ({
4
+ internalType: string;
5
+ name: string;
6
+ type: string;
7
+ components?: undefined;
8
+ } | {
9
+ components: {
10
+ internalType: string;
11
+ name: string;
12
+ type: string;
13
+ }[];
14
+ internalType: string;
15
+ name: string;
16
+ type: string;
17
+ })[];
18
+ name: string;
19
+ outputs: ({
20
+ internalType: string;
21
+ name: string;
22
+ type: string;
23
+ components?: undefined;
24
+ } | {
25
+ components: {
26
+ internalType: string;
27
+ name: string;
28
+ type: string;
29
+ }[];
30
+ internalType: string;
31
+ name: string;
32
+ type: string;
33
+ })[];
34
+ stateMutability: string;
35
+ type: string;
36
+ }[];
37
+ };