@obolnetwork/obol-sdk 2.10.2 → 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 (51) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/abi/BatchDeposit.js +120 -0
  3. package/dist/cjs/src/abi/Multicall3.js +253 -0
  4. package/dist/cjs/src/bytecodes.js +4 -4
  5. package/dist/cjs/src/constants.js +13 -7
  6. package/dist/cjs/src/eoa/eoa.js +48 -0
  7. package/dist/cjs/src/eoa/eoaHelpers.js +45 -1
  8. package/dist/cjs/src/index.js +2 -2
  9. package/dist/cjs/src/schema.js +83 -1
  10. package/dist/cjs/src/splits/splitHelpers.js +64 -19
  11. package/dist/cjs/src/splits/splits.js +54 -11
  12. package/dist/cjs/test/eoa/eoa.spec.js +75 -0
  13. package/dist/cjs/test/splits/splits.spec.js +84 -0
  14. package/dist/esm/package.json +1 -1
  15. package/dist/esm/src/abi/BatchDeposit.js +117 -0
  16. package/dist/esm/src/abi/Multicall3.js +250 -0
  17. package/dist/esm/src/bytecodes.js +3 -3
  18. package/dist/esm/src/constants.js +14 -8
  19. package/dist/esm/src/eoa/eoa.js +50 -2
  20. package/dist/esm/src/eoa/eoaHelpers.js +43 -0
  21. package/dist/esm/src/index.js +2 -2
  22. package/dist/esm/src/schema.js +82 -0
  23. package/dist/esm/src/splits/splitHelpers.js +61 -17
  24. package/dist/esm/src/splits/splits.js +56 -13
  25. package/dist/esm/test/eoa/eoa.spec.js +76 -1
  26. package/dist/esm/test/splits/splits.spec.js +85 -1
  27. package/dist/types/src/abi/BatchDeposit.d.ts +49 -0
  28. package/dist/types/src/abi/Multicall3.d.ts +37 -0
  29. package/dist/types/src/bytecodes.d.ts +3 -3
  30. package/dist/types/src/eoa/eoa.d.ts +34 -1
  31. package/dist/types/src/eoa/eoaHelpers.d.ts +15 -0
  32. package/dist/types/src/schema.d.ts +76 -0
  33. package/dist/types/src/splits/splitHelpers.d.ts +22 -1
  34. package/dist/types/src/splits/splits.d.ts +33 -1
  35. package/dist/types/src/types.d.ts +40 -1
  36. package/package.json +1 -1
  37. package/src/abi/BatchDeposit.ts +117 -0
  38. package/src/abi/Multicall3.ts +250 -0
  39. package/src/bytecodes.ts +3 -3
  40. package/src/constants.ts +16 -10
  41. package/src/eoa/eoa.ts +60 -2
  42. package/src/eoa/eoaHelpers.ts +68 -0
  43. package/src/index.ts +4 -4
  44. package/src/schema.ts +84 -0
  45. package/src/splits/splitHelpers.ts +99 -19
  46. package/src/splits/splits.ts +65 -15
  47. package/src/types.ts +43 -1
  48. package/dist/cjs/src/abi/Multicall.js +0 -148
  49. package/dist/esm/src/abi/Multicall.js +0 -145
  50. package/dist/types/src/abi/Multicall.d.ts +0 -35
  51. package/src/abi/Multicall.ts +0 -145
@@ -22,6 +22,7 @@ jest.mock('../../src/splits/splitHelpers', () => ({
22
22
  deployOVMContract: jest.fn(),
23
23
  deployOVMAndSplitV2: jest.fn(),
24
24
  requestWithdrawalFromOVM: jest.fn(),
25
+ depositWithMulticall3: jest.fn(),
25
26
  }));
26
27
  // Mock the utils
27
28
  jest.mock('../../src/utils', () => ({
@@ -38,6 +39,7 @@ const mockIsSplitV2Deployed = splitHelpers_1.isSplitV2Deployed;
38
39
  const mockDeployOVMAndSplitV2 = splitHelpers_1.deployOVMAndSplitV2;
39
40
  const mockDeployOVMContract = splitHelpers_1.deployOVMContract;
40
41
  const mockRequestWithdrawalFromOVM = splitHelpers_1.requestWithdrawalFromOVM;
42
+ const mockdepositWithMulticall3 = splitHelpers_1.depositWithMulticall3;
41
43
  const mockIsContractAvailable = utils_1.isContractAvailable;
42
44
  describe('ObolSplits', () => {
43
45
  let client;
@@ -307,6 +309,88 @@ describe('ObolSplits', () => {
307
309
  });
308
310
  }));
309
311
  });
312
+ describe('deposit', () => {
313
+ const mockOVMAddress = '0x1234567890123456789012345678901234567890';
314
+ const mockDeposits = [
315
+ {
316
+ pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
317
+ withdrawal_credentials: '0x1234567890123456789012345678901234567890',
318
+ signature: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
319
+ deposit_data_root: '0x1234567890123456789012345678901234567890123456789012345678901234',
320
+ amount: '32000000000000000000', // 32 ETH in wei
321
+ },
322
+ ];
323
+ beforeEach(() => {
324
+ mockdepositWithMulticall3.mockReset();
325
+ });
326
+ it('should successfully deposit to OVM with multicall3', () => __awaiter(void 0, void 0, void 0, function* () {
327
+ mockdepositWithMulticall3.mockResolvedValue({
328
+ txHashes: [
329
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
330
+ ],
331
+ });
332
+ const result = yield client.splits.deposit({
333
+ ovmAddress: mockOVMAddress,
334
+ deposits: mockDeposits,
335
+ });
336
+ expect(result).toEqual({
337
+ txHashes: [
338
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
339
+ ],
340
+ });
341
+ expect(mockdepositWithMulticall3).toHaveBeenCalledWith({
342
+ ovmAddress: mockOVMAddress,
343
+ deposits: mockDeposits,
344
+ signer: mockSigner,
345
+ chainId: 1,
346
+ });
347
+ }));
348
+ it('should throw error when signer is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
349
+ const clientWithoutSigner = new src_1.Client({ chainId: 1 }, undefined, mockProvider);
350
+ yield expect(clientWithoutSigner.splits.deposit({
351
+ ovmAddress: mockOVMAddress,
352
+ deposits: mockDeposits,
353
+ })).rejects.toThrow('Signer is required in deposit');
354
+ }));
355
+ it('should handle multiple deposits', () => __awaiter(void 0, void 0, void 0, function* () {
356
+ const multipleDeposits = [
357
+ {
358
+ pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
359
+ withdrawal_credentials: '0x1234567890123456789012345678901234567890',
360
+ signature: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
361
+ deposit_data_root: '0x1234567890123456789012345678901234567890123456789012345678901234',
362
+ amount: '32000000000000000000', // 32 ETH in wei
363
+ },
364
+ {
365
+ pubkey: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
366
+ withdrawal_credentials: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
367
+ signature: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
368
+ deposit_data_root: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
369
+ amount: '16000000000000000000', // 16 ETH in wei
370
+ },
371
+ ];
372
+ mockdepositWithMulticall3.mockResolvedValue({
373
+ txHashes: [
374
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
375
+ ],
376
+ });
377
+ const result = yield client.splits.deposit({
378
+ ovmAddress: mockOVMAddress,
379
+ deposits: multipleDeposits,
380
+ });
381
+ expect(result).toEqual({
382
+ txHashes: [
383
+ '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
384
+ ],
385
+ });
386
+ expect(mockdepositWithMulticall3).toHaveBeenCalledWith({
387
+ ovmAddress: mockOVMAddress,
388
+ deposits: multipleDeposits,
389
+ signer: mockSigner,
390
+ chainId: 1,
391
+ });
392
+ }));
393
+ });
310
394
  describe('constructor', () => {
311
395
  it('should create Client instance with splits property', () => {
312
396
  const testClient = new src_1.Client({ chainId: 1 }, mockSigner, mockProvider);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.10.2",
3
+ "version": "2.11.0",
4
4
  "description": "A package for creating Distributed Validators using the Obol API.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/obolnetwork/obol-sdk/issues"
@@ -0,0 +1,117 @@
1
+ export const BatchDepositContract = {
2
+ abi: [
3
+ {
4
+ inputs: [],
5
+ name: 'DepositValueGreaterThan2048ETH',
6
+ type: 'error',
7
+ },
8
+ {
9
+ inputs: [],
10
+ name: 'DepositValueLessThan1ETH',
11
+ type: 'error',
12
+ },
13
+ {
14
+ inputs: [],
15
+ name: 'DepositValueMustBeMultipleOfGwei',
16
+ type: 'error',
17
+ },
18
+ {
19
+ inputs: [],
20
+ name: 'InvalidPubKeyLength',
21
+ type: 'error',
22
+ },
23
+ {
24
+ inputs: [],
25
+ name: 'InvalidSignatureLength',
26
+ type: 'error',
27
+ },
28
+ {
29
+ inputs: [],
30
+ name: 'InvalidWithdrawalCredLength',
31
+ type: 'error',
32
+ },
33
+ {
34
+ inputs: [],
35
+ name: 'MsgValueNotEqualToTotalDepositAmount',
36
+ type: 'error',
37
+ },
38
+ {
39
+ inputs: [],
40
+ name: 'NoDepositsProvided',
41
+ type: 'error',
42
+ },
43
+ {
44
+ anonymous: false,
45
+ inputs: [
46
+ {
47
+ indexed: true,
48
+ internalType: 'bytes',
49
+ name: 'pubKey',
50
+ type: 'bytes',
51
+ },
52
+ {
53
+ indexed: true,
54
+ internalType: 'bytes',
55
+ name: 'withdrawalCredentials',
56
+ type: 'bytes',
57
+ },
58
+ {
59
+ indexed: false,
60
+ internalType: 'uint256',
61
+ name: 'amount',
62
+ type: 'uint256',
63
+ },
64
+ ],
65
+ name: 'ValidatorDeposit',
66
+ type: 'event',
67
+ },
68
+ {
69
+ inputs: [
70
+ {
71
+ components: [
72
+ {
73
+ internalType: 'bytes',
74
+ name: 'pubKey',
75
+ type: 'bytes',
76
+ },
77
+ {
78
+ internalType: 'bytes',
79
+ name: 'withdrawalCredentials',
80
+ type: 'bytes',
81
+ },
82
+ {
83
+ internalType: 'bytes',
84
+ name: 'signature',
85
+ type: 'bytes',
86
+ },
87
+ {
88
+ internalType: 'uint256',
89
+ name: 'amount',
90
+ type: 'uint256',
91
+ },
92
+ ],
93
+ internalType: 'struct IBatchDeposit.Deposit[]',
94
+ name: '_deposits',
95
+ type: 'tuple[]',
96
+ },
97
+ ],
98
+ name: 'batchDeposit',
99
+ outputs: [],
100
+ stateMutability: 'payable',
101
+ type: 'function',
102
+ },
103
+ {
104
+ inputs: [],
105
+ name: 'depositContract',
106
+ outputs: [
107
+ {
108
+ internalType: 'contract IDepositContract',
109
+ name: '',
110
+ type: 'address',
111
+ },
112
+ ],
113
+ stateMutability: 'view',
114
+ type: 'function',
115
+ },
116
+ ],
117
+ };
@@ -0,0 +1,250 @@
1
+ export const MultiCall3Contract = {
2
+ abi: [
3
+ {
4
+ inputs: [
5
+ {
6
+ components: [
7
+ { internalType: 'address', name: 'target', type: 'address' },
8
+ { internalType: 'bytes', name: 'callData', type: 'bytes' },
9
+ ],
10
+ internalType: 'struct Multicall3.Call[]',
11
+ name: 'calls',
12
+ type: 'tuple[]',
13
+ },
14
+ ],
15
+ name: 'aggregate',
16
+ outputs: [
17
+ { internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
18
+ { internalType: 'bytes[]', name: 'returnData', type: 'bytes[]' },
19
+ ],
20
+ stateMutability: 'payable',
21
+ type: 'function',
22
+ },
23
+ {
24
+ inputs: [
25
+ {
26
+ components: [
27
+ { internalType: 'address', name: 'target', type: 'address' },
28
+ { internalType: 'bool', name: 'allowFailure', type: 'bool' },
29
+ { internalType: 'bytes', name: 'callData', type: 'bytes' },
30
+ ],
31
+ internalType: 'struct Multicall3.Call3[]',
32
+ name: 'calls',
33
+ type: 'tuple[]',
34
+ },
35
+ ],
36
+ name: 'aggregate3',
37
+ outputs: [
38
+ {
39
+ components: [
40
+ { internalType: 'bool', name: 'success', type: 'bool' },
41
+ { internalType: 'bytes', name: 'returnData', type: 'bytes' },
42
+ ],
43
+ internalType: 'struct Multicall3.Result[]',
44
+ name: 'returnData',
45
+ type: 'tuple[]',
46
+ },
47
+ ],
48
+ stateMutability: 'payable',
49
+ type: 'function',
50
+ },
51
+ {
52
+ inputs: [
53
+ {
54
+ components: [
55
+ { internalType: 'address', name: 'target', type: 'address' },
56
+ { internalType: 'bool', name: 'allowFailure', type: 'bool' },
57
+ { internalType: 'uint256', name: 'value', type: 'uint256' },
58
+ { internalType: 'bytes', name: 'callData', type: 'bytes' },
59
+ ],
60
+ internalType: 'struct Multicall3.Call3Value[]',
61
+ name: 'calls',
62
+ type: 'tuple[]',
63
+ },
64
+ ],
65
+ name: 'aggregate3Value',
66
+ outputs: [
67
+ {
68
+ components: [
69
+ { internalType: 'bool', name: 'success', type: 'bool' },
70
+ { internalType: 'bytes', name: 'returnData', type: 'bytes' },
71
+ ],
72
+ internalType: 'struct Multicall3.Result[]',
73
+ name: 'returnData',
74
+ type: 'tuple[]',
75
+ },
76
+ ],
77
+ stateMutability: 'payable',
78
+ type: 'function',
79
+ },
80
+ {
81
+ inputs: [
82
+ {
83
+ components: [
84
+ { internalType: 'address', name: 'target', type: 'address' },
85
+ { internalType: 'bytes', name: 'callData', type: 'bytes' },
86
+ ],
87
+ internalType: 'struct Multicall3.Call[]',
88
+ name: 'calls',
89
+ type: 'tuple[]',
90
+ },
91
+ ],
92
+ name: 'blockAndAggregate',
93
+ outputs: [
94
+ { internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
95
+ { internalType: 'bytes32', name: 'blockHash', type: 'bytes32' },
96
+ {
97
+ components: [
98
+ { internalType: 'bool', name: 'success', type: 'bool' },
99
+ { internalType: 'bytes', name: 'returnData', type: 'bytes' },
100
+ ],
101
+ internalType: 'struct Multicall3.Result[]',
102
+ name: 'returnData',
103
+ type: 'tuple[]',
104
+ },
105
+ ],
106
+ stateMutability: 'payable',
107
+ type: 'function',
108
+ },
109
+ {
110
+ inputs: [],
111
+ name: 'getBasefee',
112
+ outputs: [{ internalType: 'uint256', name: 'basefee', type: 'uint256' }],
113
+ stateMutability: 'view',
114
+ type: 'function',
115
+ },
116
+ {
117
+ inputs: [
118
+ { internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
119
+ ],
120
+ name: 'getBlockHash',
121
+ outputs: [
122
+ { internalType: 'bytes32', name: 'blockHash', type: 'bytes32' },
123
+ ],
124
+ stateMutability: 'view',
125
+ type: 'function',
126
+ },
127
+ {
128
+ inputs: [],
129
+ name: 'getBlockNumber',
130
+ outputs: [
131
+ { internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
132
+ ],
133
+ stateMutability: 'view',
134
+ type: 'function',
135
+ },
136
+ {
137
+ inputs: [],
138
+ name: 'getChainId',
139
+ outputs: [{ internalType: 'uint256', name: 'chainid', type: 'uint256' }],
140
+ stateMutability: 'view',
141
+ type: 'function',
142
+ },
143
+ {
144
+ inputs: [],
145
+ name: 'getCurrentBlockCoinbase',
146
+ outputs: [{ internalType: 'address', name: 'coinbase', type: 'address' }],
147
+ stateMutability: 'view',
148
+ type: 'function',
149
+ },
150
+ {
151
+ inputs: [],
152
+ name: 'getCurrentBlockDifficulty',
153
+ outputs: [
154
+ { internalType: 'uint256', name: 'difficulty', type: 'uint256' },
155
+ ],
156
+ stateMutability: 'view',
157
+ type: 'function',
158
+ },
159
+ {
160
+ inputs: [],
161
+ name: 'getCurrentBlockGasLimit',
162
+ outputs: [{ internalType: 'uint256', name: 'gaslimit', type: 'uint256' }],
163
+ stateMutability: 'view',
164
+ type: 'function',
165
+ },
166
+ {
167
+ inputs: [],
168
+ name: 'getCurrentBlockTimestamp',
169
+ outputs: [
170
+ { internalType: 'uint256', name: 'timestamp', type: 'uint256' },
171
+ ],
172
+ stateMutability: 'view',
173
+ type: 'function',
174
+ },
175
+ {
176
+ inputs: [{ internalType: 'address', name: 'addr', type: 'address' }],
177
+ name: 'getEthBalance',
178
+ outputs: [{ internalType: 'uint256', name: 'balance', type: 'uint256' }],
179
+ stateMutability: 'view',
180
+ type: 'function',
181
+ },
182
+ {
183
+ inputs: [],
184
+ name: 'getLastBlockHash',
185
+ outputs: [
186
+ { internalType: 'bytes32', name: 'blockHash', type: 'bytes32' },
187
+ ],
188
+ stateMutability: 'view',
189
+ type: 'function',
190
+ },
191
+ {
192
+ inputs: [
193
+ { internalType: 'bool', name: 'requireSuccess', type: 'bool' },
194
+ {
195
+ components: [
196
+ { internalType: 'address', name: 'target', type: 'address' },
197
+ { internalType: 'bytes', name: 'callData', type: 'bytes' },
198
+ ],
199
+ internalType: 'struct Multicall3.Call[]',
200
+ name: 'calls',
201
+ type: 'tuple[]',
202
+ },
203
+ ],
204
+ name: 'tryAggregate',
205
+ outputs: [
206
+ {
207
+ components: [
208
+ { internalType: 'bool', name: 'success', type: 'bool' },
209
+ { internalType: 'bytes', name: 'returnData', type: 'bytes' },
210
+ ],
211
+ internalType: 'struct Multicall3.Result[]',
212
+ name: 'returnData',
213
+ type: 'tuple[]',
214
+ },
215
+ ],
216
+ stateMutability: 'payable',
217
+ type: 'function',
218
+ },
219
+ {
220
+ inputs: [
221
+ { internalType: 'bool', name: 'requireSuccess', type: 'bool' },
222
+ {
223
+ components: [
224
+ { internalType: 'address', name: 'target', type: 'address' },
225
+ { internalType: 'bytes', name: 'callData', type: 'bytes' },
226
+ ],
227
+ internalType: 'struct Multicall3.Call[]',
228
+ name: 'calls',
229
+ type: 'tuple[]',
230
+ },
231
+ ],
232
+ name: 'tryBlockAndAggregate',
233
+ outputs: [
234
+ { internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
235
+ { internalType: 'bytes32', name: 'blockHash', type: 'bytes32' },
236
+ {
237
+ components: [
238
+ { internalType: 'bool', name: 'success', type: 'bool' },
239
+ { internalType: 'bytes', name: 'returnData', type: 'bytes' },
240
+ ],
241
+ internalType: 'struct Multicall3.Result[]',
242
+ name: 'returnData',
243
+ type: 'tuple[]',
244
+ },
245
+ ],
246
+ stateMutability: 'payable',
247
+ type: 'function',
248
+ },
249
+ ],
250
+ };