@obolnetwork/obol-sdk 2.10.2 → 2.11.2
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.
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/abi/BatchDeposit.js +120 -0
- package/dist/cjs/src/abi/Multicall3.js +253 -0
- package/dist/cjs/src/bytecodes.js +4 -4
- package/dist/cjs/src/constants.js +13 -7
- package/dist/cjs/src/eoa/eoa.js +49 -0
- package/dist/cjs/src/eoa/eoaHelpers.js +46 -1
- package/dist/cjs/src/index.js +2 -2
- package/dist/cjs/src/schema.js +93 -1
- package/dist/cjs/src/splits/splitHelpers.js +64 -19
- package/dist/cjs/src/splits/splits.js +54 -11
- package/dist/cjs/test/eoa/eoa.spec.js +78 -0
- package/dist/cjs/test/splits/splits.spec.js +84 -0
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/abi/BatchDeposit.js +117 -0
- package/dist/esm/src/abi/Multicall3.js +250 -0
- package/dist/esm/src/bytecodes.js +3 -3
- package/dist/esm/src/constants.js +14 -8
- package/dist/esm/src/eoa/eoa.js +51 -2
- package/dist/esm/src/eoa/eoaHelpers.js +44 -0
- package/dist/esm/src/index.js +2 -2
- package/dist/esm/src/schema.js +92 -0
- package/dist/esm/src/splits/splitHelpers.js +61 -17
- package/dist/esm/src/splits/splits.js +56 -13
- package/dist/esm/test/eoa/eoa.spec.js +79 -1
- package/dist/esm/test/splits/splits.spec.js +85 -1
- package/dist/types/src/abi/BatchDeposit.d.ts +49 -0
- package/dist/types/src/abi/Multicall3.d.ts +37 -0
- package/dist/types/src/bytecodes.d.ts +3 -3
- package/dist/types/src/eoa/eoa.d.ts +35 -1
- package/dist/types/src/eoa/eoaHelpers.d.ts +16 -0
- package/dist/types/src/schema.d.ts +80 -0
- package/dist/types/src/splits/splitHelpers.d.ts +22 -1
- package/dist/types/src/splits/splits.d.ts +33 -1
- package/dist/types/src/types.d.ts +42 -1
- package/package.json +1 -1
- package/src/abi/BatchDeposit.ts +117 -0
- package/src/abi/Multicall3.ts +250 -0
- package/src/bytecodes.ts +4 -4
- package/src/constants.ts +16 -10
- package/src/eoa/eoa.ts +61 -2
- package/src/eoa/eoaHelpers.ts +70 -0
- package/src/index.ts +4 -4
- package/src/schema.ts +94 -0
- package/src/splits/splitHelpers.ts +99 -19
- package/src/splits/splits.ts +65 -15
- package/src/types.ts +45 -1
- package/dist/cjs/src/abi/Multicall.js +0 -148
- package/dist/esm/src/abi/Multicall.js +0 -145
- package/dist/types/src/abi/Multicall.d.ts +0 -35
- 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,81 @@ describe('EOA', () => {
|
|
|
93
94
|
expect(result).toEqual(mockResult);
|
|
94
95
|
}));
|
|
95
96
|
});
|
|
97
|
+
describe('deposit', () => {
|
|
98
|
+
const mockDeposits = [
|
|
99
|
+
{
|
|
100
|
+
pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
|
|
101
|
+
withdrawal_credentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
|
|
102
|
+
deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
|
|
103
|
+
signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
|
|
104
|
+
amount: '32000000000000000000', // 32 ETH in wei
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
it('should successfully deposit to batch contract', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
const mockPayload = {
|
|
109
|
+
deposits: mockDeposits,
|
|
110
|
+
};
|
|
111
|
+
const mockResult = {
|
|
112
|
+
txHashes: [
|
|
113
|
+
'0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
submitEOABatchDeposit.mockResolvedValue(mockResult);
|
|
117
|
+
const result = yield eoa.deposit(mockPayload);
|
|
118
|
+
expect(submitEOABatchDeposit).toHaveBeenCalledWith({
|
|
119
|
+
deposits: mockDeposits,
|
|
120
|
+
batchDepositContractAddress: '0xcD7a6C118Ac8F6544BC5076F2D8Fb86D2C546756',
|
|
121
|
+
signer: mockSigner,
|
|
122
|
+
});
|
|
123
|
+
expect(result).toEqual(mockResult);
|
|
124
|
+
}));
|
|
125
|
+
it('should throw error when signer is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
const eoaWithoutSigner = new EOA(undefined, 1, mockProvider);
|
|
127
|
+
const mockPayload = {
|
|
128
|
+
deposits: mockDeposits,
|
|
129
|
+
};
|
|
130
|
+
yield expect(eoaWithoutSigner.deposit(mockPayload)).rejects.toThrow('Signer is required in deposit');
|
|
131
|
+
}));
|
|
132
|
+
it('should throw error when batch deposit contract is not configured for chain', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
const eoaUnsupportedChain = new EOA(mockSigner, 999, mockProvider);
|
|
134
|
+
const mockPayload = {
|
|
135
|
+
deposits: mockDeposits,
|
|
136
|
+
};
|
|
137
|
+
yield expect(eoaUnsupportedChain.deposit(mockPayload)).rejects.toThrow('Batch deposit contract is not configured for chain 999');
|
|
138
|
+
}));
|
|
139
|
+
it('should handle multiple deposits', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
const multipleDeposits = [
|
|
141
|
+
{
|
|
142
|
+
pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
|
|
143
|
+
withdrawal_credentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
|
|
144
|
+
deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
|
|
145
|
+
signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
|
|
146
|
+
amount: '32000000000000000000',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
pubkey: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdcd',
|
|
150
|
+
withdrawal_credentials: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
|
|
151
|
+
deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
|
|
152
|
+
signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
|
|
153
|
+
amount: '16000000000000000000',
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
const mockPayload = {
|
|
157
|
+
deposits: multipleDeposits,
|
|
158
|
+
};
|
|
159
|
+
const mockResult = {
|
|
160
|
+
txHashes: [
|
|
161
|
+
'0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
submitEOABatchDeposit.mockResolvedValue(mockResult);
|
|
165
|
+
const result = yield eoa.deposit(mockPayload);
|
|
166
|
+
expect(submitEOABatchDeposit).toHaveBeenCalledWith({
|
|
167
|
+
deposits: multipleDeposits,
|
|
168
|
+
batchDepositContractAddress: '0xcD7a6C118Ac8F6544BC5076F2D8Fb86D2C546756',
|
|
169
|
+
signer: mockSigner,
|
|
170
|
+
});
|
|
171
|
+
expect(result).toEqual(mockResult);
|
|
172
|
+
}));
|
|
173
|
+
});
|
|
96
174
|
});
|
|
@@ -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
|
+
};
|