@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.
- 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 +48 -0
- package/dist/cjs/src/eoa/eoaHelpers.js +45 -1
- package/dist/cjs/src/index.js +2 -2
- package/dist/cjs/src/schema.js +83 -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 +75 -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 +50 -2
- package/dist/esm/src/eoa/eoaHelpers.js +43 -0
- package/dist/esm/src/index.js +2 -2
- package/dist/esm/src/schema.js +82 -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 +76 -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 +34 -1
- package/dist/types/src/eoa/eoaHelpers.d.ts +15 -0
- package/dist/types/src/schema.d.ts +76 -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 +40 -1
- package/package.json +1 -1
- package/src/abi/BatchDeposit.ts +117 -0
- package/src/abi/Multicall3.ts +250 -0
- package/src/bytecodes.ts +3 -3
- package/src/constants.ts +16 -10
- package/src/eoa/eoa.ts +60 -2
- package/src/eoa/eoaHelpers.ts +68 -0
- package/src/index.ts +4 -4
- package/src/schema.ts +84 -0
- package/src/splits/splitHelpers.ts +99 -19
- package/src/splits/splits.ts +65 -15
- package/src/types.ts +43 -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
|
@@ -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
|
+
};
|