@obolnetwork/obol-sdk 2.11.4 → 2.11.5-rc.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/src/index.js +17457 -382
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/esm/src/index.js +17424 -361
- package/dist/esm/src/index.js.map +1 -0
- package/dist/types/src/constants.d.ts +1 -2
- package/dist/types/src/eoa/eoaHelpers.d.ts +1 -1
- package/dist/types/src/exits/verificationHelpers.d.ts +0 -2
- package/dist/types/src/incentives/incentiveHelpers.d.ts +1 -1
- package/dist/types/src/splits/splitHelpers.d.ts +3 -3
- package/dist/types/src/utils.d.ts +2 -2
- package/dist/types/src/verification/common.d.ts +0 -2
- package/dist/types/src/verification/signature-validator.d.ts +4 -4
- package/dist/types/src/verification/v1.10.0.d.ts +1 -1
- package/dist/types/src/verification/v1.6.0.d.ts +1 -1
- package/dist/types/src/verification/v1.7.0.d.ts +1 -1
- package/dist/types/src/verification/v1.8.0.d.ts +1 -1
- package/dist/types/test/client/methods.spec.d.ts +17 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/tsup.config.d.ts +2 -0
- package/package.json +79 -54
- package/dist/cjs/package.json +0 -139
- package/dist/cjs/src/abi/BatchDeposit.js +0 -120
- package/dist/cjs/src/abi/MerkleDistributorWithDeadline.js +0 -73
- package/dist/cjs/src/abi/Multicall3.js +0 -253
- package/dist/cjs/src/abi/OVM.js +0 -627
- package/dist/cjs/src/abi/OWR.js +0 -304
- package/dist/cjs/src/abi/SplitMain.js +0 -929
- package/dist/cjs/src/abi/splitV2FactoryAbi.js +0 -420
- package/dist/cjs/src/ajv.js +0 -136
- package/dist/cjs/src/base.js +0 -42
- package/dist/cjs/src/bytecodes.js +0 -19
- package/dist/cjs/src/constants.js +0 -272
- package/dist/cjs/src/eoa/eoa.js +0 -132
- package/dist/cjs/src/eoa/eoaHelpers.js +0 -82
- package/dist/cjs/src/errors.js +0 -11
- package/dist/cjs/src/exits/ethUtils.js +0 -57
- package/dist/cjs/src/exits/exit.js +0 -502
- package/dist/cjs/src/exits/verificationHelpers.js +0 -86
- package/dist/cjs/src/incentives/incentiveHelpers.js +0 -39
- package/dist/cjs/src/incentives/incentives.js +0 -119
- package/dist/cjs/src/schema.js +0 -352
- package/dist/cjs/src/services.js +0 -33
- package/dist/cjs/src/splits/splitHelpers.js +0 -571
- package/dist/cjs/src/splits/splits.js +0 -366
- package/dist/cjs/src/types.js +0 -29
- package/dist/cjs/src/utils.js +0 -77
- package/dist/cjs/src/verification/common.js +0 -355
- package/dist/cjs/src/verification/signature-validator.js +0 -73
- package/dist/cjs/src/verification/sszTypes.js +0 -69
- package/dist/cjs/src/verification/termsAndConditions.js +0 -40
- package/dist/cjs/src/verification/v1.10.0.js +0 -146
- package/dist/cjs/src/verification/v1.6.0.js +0 -149
- package/dist/cjs/src/verification/v1.7.0.js +0 -173
- package/dist/cjs/src/verification/v1.8.0.js +0 -196
- package/dist/cjs/test/client/ajv.spec.js +0 -320
- package/dist/cjs/test/client/methods.spec.js +0 -418
- package/dist/cjs/test/eoa/eoa.spec.js +0 -176
- package/dist/cjs/test/exit/ethUtils.spec.js +0 -83
- package/dist/cjs/test/exit/exit.spec.js +0 -399
- package/dist/cjs/test/exit/verificationHelpers.spec.js +0 -68
- package/dist/cjs/test/fixtures.js +0 -896
- package/dist/cjs/test/incentives/incentives.spec.js +0 -202
- package/dist/cjs/test/splits/splits.spec.js +0 -402
- package/dist/esm/package.json +0 -139
- package/dist/esm/src/abi/BatchDeposit.js +0 -117
- package/dist/esm/src/abi/MerkleDistributorWithDeadline.js +0 -70
- package/dist/esm/src/abi/Multicall3.js +0 -250
- package/dist/esm/src/abi/OVM.js +0 -624
- package/dist/esm/src/abi/OWR.js +0 -301
- package/dist/esm/src/abi/SplitMain.js +0 -926
- package/dist/esm/src/abi/splitV2FactoryAbi.js +0 -417
- package/dist/esm/src/ajv.js +0 -129
- package/dist/esm/src/base.js +0 -38
- package/dist/esm/src/bytecodes.js +0 -16
- package/dist/esm/src/constants.js +0 -238
- package/dist/esm/src/eoa/eoa.js +0 -128
- package/dist/esm/src/eoa/eoaHelpers.js +0 -77
- package/dist/esm/src/errors.js +0 -7
- package/dist/esm/src/exits/ethUtils.js +0 -52
- package/dist/esm/src/exits/exit.js +0 -475
- package/dist/esm/src/exits/verificationHelpers.js +0 -81
- package/dist/esm/src/incentives/incentiveHelpers.js +0 -34
- package/dist/esm/src/incentives/incentives.js +0 -115
- package/dist/esm/src/schema.js +0 -349
- package/dist/esm/src/services.js +0 -29
- package/dist/esm/src/splits/splitHelpers.js +0 -554
- package/dist/esm/src/splits/splits.js +0 -362
- package/dist/esm/src/types.js +0 -26
- package/dist/esm/src/utils.js +0 -68
- package/dist/esm/src/verification/common.js +0 -319
- package/dist/esm/src/verification/signature-validator.js +0 -64
- package/dist/esm/src/verification/sszTypes.js +0 -64
- package/dist/esm/src/verification/termsAndConditions.js +0 -33
- package/dist/esm/src/verification/v1.10.0.js +0 -140
- package/dist/esm/src/verification/v1.6.0.js +0 -142
- package/dist/esm/src/verification/v1.7.0.js +0 -166
- package/dist/esm/src/verification/v1.8.0.js +0 -189
- package/dist/esm/test/client/ajv.spec.js +0 -318
- package/dist/esm/test/client/methods.spec.js +0 -393
- package/dist/esm/test/eoa/eoa.spec.js +0 -174
- package/dist/esm/test/exit/ethUtils.spec.js +0 -81
- package/dist/esm/test/exit/exit.spec.js +0 -374
- package/dist/esm/test/exit/verificationHelpers.spec.js +0 -66
- package/dist/esm/test/fixtures.js +0 -893
- package/dist/esm/test/incentives/incentives.spec.js +0 -177
- package/dist/esm/test/splits/splits.spec.js +0 -400
- package/src/abi/BatchDeposit.ts +0 -117
- package/src/abi/MerkleDistributorWithDeadline.ts +0 -70
- package/src/abi/Multicall3.ts +0 -250
- package/src/abi/OVM.ts +0 -624
- package/src/abi/OWR.ts +0 -302
- package/src/abi/SplitMain.ts +0 -927
- package/src/abi/splitV2FactoryAbi.ts +0 -417
- package/src/ajv.ts +0 -191
- package/src/base.ts +0 -54
- package/src/bytecodes.ts +0 -32
- package/src/constants.ts +0 -309
- package/src/eoa/eoa.ts +0 -153
- package/src/eoa/eoaHelpers.ts +0 -112
- package/src/errors.ts +0 -8
- package/src/exits/ethUtils.ts +0 -49
- package/src/exits/exit.ts +0 -661
- package/src/exits/verificationHelpers.ts +0 -110
- package/src/incentives/incentiveHelpers.ts +0 -55
- package/src/incentives/incentives.ts +0 -153
- package/src/index.ts +0 -614
- package/src/schema.ts +0 -376
- package/src/services.ts +0 -24
- package/src/splits/splitHelpers.ts +0 -1032
- package/src/splits/splits.ts +0 -504
- package/src/types.ts +0 -687
- package/src/utils.ts +0 -88
- package/src/verification/common.ts +0 -532
- package/src/verification/signature-validator.ts +0 -103
- package/src/verification/sszTypes.ts +0 -88
- package/src/verification/termsAndConditions.ts +0 -32
- package/src/verification/v1.10.0.ts +0 -245
- package/src/verification/v1.6.0.ts +0 -256
- package/src/verification/v1.7.0.ts +0 -309
- package/src/verification/v1.8.0.ts +0 -340
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var _a, _b;
|
|
11
|
-
import { ethers, JsonRpcProvider } from 'ethers';
|
|
12
|
-
import { Client } from '../../src/index';
|
|
13
|
-
import * as utils from '../../src/utils';
|
|
14
|
-
import * as incentivesHelpers from '../../src/incentives/incentiveHelpers';
|
|
15
|
-
import { DEFAULT_BASE_VERSION } from '../../src/constants';
|
|
16
|
-
import { jest, describe, beforeEach, test, expect } from '@jest/globals';
|
|
17
|
-
const mnemonic = (_b = (_a = ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
|
|
18
|
-
const privateKey = ethers.Wallet.fromPhrase(mnemonic).privateKey;
|
|
19
|
-
const provider = new JsonRpcProvider('https://ethereum-holesky.publicnode.com');
|
|
20
|
-
const wallet = new ethers.Wallet(privateKey, provider);
|
|
21
|
-
const mockSigner = wallet.connect(provider);
|
|
22
|
-
const baseUrl = 'https://obol-api-dev.gcp.obol.tech';
|
|
23
|
-
// Fix the type error by properly typing the mock function
|
|
24
|
-
global.fetch = jest.fn();
|
|
25
|
-
describe('Client.incentives', () => {
|
|
26
|
-
let clientInstance;
|
|
27
|
-
const mockIncentivesData = {
|
|
28
|
-
contract_address: '0x1234567890abcdef1234567890abcdef12345678',
|
|
29
|
-
index: 5,
|
|
30
|
-
operator_address: '0xabcdef1234567890abcdef1234567890abcdef12',
|
|
31
|
-
amount: '1000000000000000000',
|
|
32
|
-
merkle_proof: [
|
|
33
|
-
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
|
|
34
|
-
'0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
35
|
-
],
|
|
36
|
-
};
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
jest.clearAllMocks();
|
|
39
|
-
clientInstance = new Client({ baseUrl, chainId: 17000 }, mockSigner);
|
|
40
|
-
global.fetch.mockReset();
|
|
41
|
-
});
|
|
42
|
-
test('claimIncentives should throw an error without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
const clientWithoutSigner = new Client({
|
|
44
|
-
baseUrl,
|
|
45
|
-
chainId: 17000,
|
|
46
|
-
});
|
|
47
|
-
yield expect(clientWithoutSigner.incentives.claimIncentives(mockIncentivesData.operator_address)).rejects.toThrow('Signer is required in claimIncentives');
|
|
48
|
-
}));
|
|
49
|
-
test('claimIncentives should throw an error if contract is not available', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
jest
|
|
51
|
-
.spyOn(clientInstance.incentives, 'getIncentivesByAddress')
|
|
52
|
-
.mockResolvedValue(mockIncentivesData);
|
|
53
|
-
jest.spyOn(clientInstance.incentives, 'isClaimed').mockResolvedValue(false);
|
|
54
|
-
jest
|
|
55
|
-
.spyOn(utils, 'isContractAvailable')
|
|
56
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(false); }));
|
|
57
|
-
yield expect(clientInstance.incentives.claimIncentives(mockIncentivesData.operator_address)).rejects.toThrow(`Merkle Distributor contract is not available at address ${mockIncentivesData.contract_address}`);
|
|
58
|
-
}));
|
|
59
|
-
test('claimIncentives should return txHash on successful claim', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
const mockTxHash = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
|
61
|
-
jest
|
|
62
|
-
.spyOn(clientInstance.incentives, 'getIncentivesByAddress')
|
|
63
|
-
.mockResolvedValue(mockIncentivesData);
|
|
64
|
-
jest.spyOn(clientInstance.incentives, 'isClaimed').mockResolvedValue(false);
|
|
65
|
-
jest
|
|
66
|
-
.spyOn(utils, 'isContractAvailable')
|
|
67
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
68
|
-
jest
|
|
69
|
-
.spyOn(incentivesHelpers, 'claimIncentivesFromMerkleDistributor')
|
|
70
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve({ txHash: mockTxHash }); }));
|
|
71
|
-
const result = yield clientInstance.incentives.claimIncentives(mockIncentivesData.operator_address);
|
|
72
|
-
expect(result).toEqual({ txHash: mockTxHash });
|
|
73
|
-
expect(incentivesHelpers.claimIncentivesFromMerkleDistributor).toHaveBeenCalledWith({
|
|
74
|
-
signer: mockSigner,
|
|
75
|
-
contractAddress: mockIncentivesData.contract_address,
|
|
76
|
-
index: mockIncentivesData.index,
|
|
77
|
-
operatorAddress: mockIncentivesData.operator_address,
|
|
78
|
-
amount: mockIncentivesData.amount,
|
|
79
|
-
merkleProof: mockIncentivesData.merkle_proof,
|
|
80
|
-
});
|
|
81
|
-
}));
|
|
82
|
-
test('claimIncentives should return txHash as null when incentives are already claimed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
jest
|
|
84
|
-
.spyOn(clientInstance.incentives, 'getIncentivesByAddress')
|
|
85
|
-
.mockResolvedValue(mockIncentivesData);
|
|
86
|
-
jest.spyOn(clientInstance.incentives, 'isClaimed').mockResolvedValue(true);
|
|
87
|
-
const result = yield clientInstance.incentives.claimIncentives(mockIncentivesData.operator_address);
|
|
88
|
-
expect(result).toEqual({ txHash: null });
|
|
89
|
-
expect(incentivesHelpers.claimIncentivesFromMerkleDistributor).not.toHaveBeenCalled();
|
|
90
|
-
}));
|
|
91
|
-
test('claimIncentives should throw an error if no incentives found for address', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
-
jest
|
|
93
|
-
.spyOn(clientInstance.incentives, 'getIncentivesByAddress')
|
|
94
|
-
.mockRejectedValue(new Error('No incentives found for address'));
|
|
95
|
-
yield expect(clientInstance.incentives.claimIncentives(mockIncentivesData.operator_address)).rejects.toThrow('Failed to claim incentives: No incentives found for address');
|
|
96
|
-
}));
|
|
97
|
-
test('claimIncentives should throw an error if helper function fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
-
jest
|
|
99
|
-
.spyOn(clientInstance.incentives, 'getIncentivesByAddress')
|
|
100
|
-
.mockResolvedValue(mockIncentivesData);
|
|
101
|
-
jest.spyOn(clientInstance.incentives, 'isClaimed').mockResolvedValue(false);
|
|
102
|
-
jest
|
|
103
|
-
.spyOn(utils, 'isContractAvailable')
|
|
104
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
105
|
-
jest
|
|
106
|
-
.spyOn(incentivesHelpers, 'claimIncentivesFromMerkleDistributor')
|
|
107
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
-
throw new Error('Helper function error');
|
|
109
|
-
}));
|
|
110
|
-
yield expect(clientInstance.incentives.claimIncentives(mockIncentivesData.operator_address)).rejects.toThrow('Failed to claim incentives: Helper function error');
|
|
111
|
-
}));
|
|
112
|
-
test('incentives should be initialized with the same chainId as client', () => {
|
|
113
|
-
const customChainId = 5;
|
|
114
|
-
const clientWithCustomChain = new Client({ baseUrl, chainId: customChainId }, mockSigner);
|
|
115
|
-
expect(clientWithCustomChain.incentives.chainId).toBe(customChainId);
|
|
116
|
-
});
|
|
117
|
-
test('isClaimed should return true when incentive is claimed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
jest
|
|
119
|
-
.spyOn(incentivesHelpers, 'isClaimedFromMerkleDistributor')
|
|
120
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
121
|
-
const result = yield clientInstance.incentives.isClaimed(mockIncentivesData.contract_address, mockIncentivesData.index);
|
|
122
|
-
expect(result).toBe(true);
|
|
123
|
-
expect(incentivesHelpers.isClaimedFromMerkleDistributor).toHaveBeenCalledWith(mockIncentivesData.contract_address, mockIncentivesData.index, {});
|
|
124
|
-
}));
|
|
125
|
-
test('isClaimed should return false when incentive is not claimed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
-
jest
|
|
127
|
-
.spyOn(incentivesHelpers, 'isClaimedFromMerkleDistributor')
|
|
128
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(false); }));
|
|
129
|
-
const result = yield clientInstance.incentives.isClaimed(mockIncentivesData.contract_address, mockIncentivesData.index);
|
|
130
|
-
expect(result).toBe(false);
|
|
131
|
-
}));
|
|
132
|
-
test('isClaimed should throw an error if helper function fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
-
jest
|
|
134
|
-
.spyOn(incentivesHelpers, 'isClaimedFromMerkleDistributor')
|
|
135
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
-
throw new Error('Helper function error');
|
|
137
|
-
}));
|
|
138
|
-
yield expect(clientInstance.incentives.isClaimed(mockIncentivesData.contract_address, mockIncentivesData.index)).rejects.toThrow('Helper function error');
|
|
139
|
-
}));
|
|
140
|
-
test('isClaimed should work with a provider and a without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
-
const clientWithoutSigner = new Client({
|
|
142
|
-
baseUrl,
|
|
143
|
-
chainId: 17000,
|
|
144
|
-
}, undefined, provider);
|
|
145
|
-
jest
|
|
146
|
-
.spyOn(incentivesHelpers, 'isClaimedFromMerkleDistributor')
|
|
147
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
148
|
-
const result = yield clientWithoutSigner.incentives.isClaimed(mockIncentivesData.contract_address, mockIncentivesData.index);
|
|
149
|
-
expect(result).toBe(true);
|
|
150
|
-
expect(incentivesHelpers.isClaimedFromMerkleDistributor).toHaveBeenCalledWith(mockIncentivesData.contract_address, mockIncentivesData.index, provider);
|
|
151
|
-
}));
|
|
152
|
-
test('getIncentivesByAddress should make the correct API request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
|
|
154
|
-
const mockIncentives = {
|
|
155
|
-
operator_address: '0x8c00157cae72c4ed6a1f8bfb60205601f0252e26',
|
|
156
|
-
amount: '100',
|
|
157
|
-
index: 1,
|
|
158
|
-
merkle_proof: ['hash1', 'hash2'],
|
|
159
|
-
contract_address: '0xContract',
|
|
160
|
-
};
|
|
161
|
-
global.fetch.mockResolvedValueOnce({
|
|
162
|
-
ok: true,
|
|
163
|
-
status: 200,
|
|
164
|
-
json: () => __awaiter(void 0, void 0, void 0, function* () { return mockIncentives; }),
|
|
165
|
-
headers: new Headers(),
|
|
166
|
-
});
|
|
167
|
-
const result = yield clientInstance.incentives.getIncentivesByAddress(mockAddress);
|
|
168
|
-
expect(result).toEqual(mockIncentives);
|
|
169
|
-
expect(global.fetch).toHaveBeenCalledWith(`${baseUrl}/${DEFAULT_BASE_VERSION}/address/incentives/holesky/${mockAddress}`, expect.objectContaining({ method: 'GET' }));
|
|
170
|
-
}));
|
|
171
|
-
test('getIncentivesByAddress should handle API errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
172
|
-
const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
|
|
173
|
-
global.fetch.mockRejectedValue(new Error('Network error'));
|
|
174
|
-
yield expect(clientInstance.incentives.getIncentivesByAddress(mockAddress)).rejects.toThrow();
|
|
175
|
-
expect(global.fetch).toHaveBeenCalled();
|
|
176
|
-
}));
|
|
177
|
-
});
|
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { Client } from '../../src';
|
|
11
|
-
import { CHAIN_CONFIGURATION } from '../../src/constants';
|
|
12
|
-
import { formatRecipientsForSplitV2, predictSplitV2Address, isSplitV2Deployed, deployOVMAndSplitV2, deployOVMContract, requestWithdrawalFromOVM, depositWithMulticall3, } from '../../src/splits/splitHelpers';
|
|
13
|
-
import { isContractAvailable } from '../../src/utils';
|
|
14
|
-
import { TEST_ADDRESSES } from '../fixtures';
|
|
15
|
-
// Mock the split helpers
|
|
16
|
-
jest.mock('../../src/splits/splitHelpers', () => ({
|
|
17
|
-
formatRecipientsForSplitV2: jest.fn(),
|
|
18
|
-
predictSplitV2Address: jest.fn(),
|
|
19
|
-
isSplitV2Deployed: jest.fn(),
|
|
20
|
-
deployOVMContract: jest.fn(),
|
|
21
|
-
deployOVMAndSplitV2: jest.fn(),
|
|
22
|
-
requestWithdrawalFromOVM: jest.fn(),
|
|
23
|
-
depositWithMulticall3: jest.fn(),
|
|
24
|
-
}));
|
|
25
|
-
// Mock the utils
|
|
26
|
-
jest.mock('../../src/utils', () => ({
|
|
27
|
-
isContractAvailable: jest.fn(),
|
|
28
|
-
}));
|
|
29
|
-
// Mock the validation
|
|
30
|
-
jest.mock('../../src/ajv', () => ({
|
|
31
|
-
validatePayload: jest.fn(data => data),
|
|
32
|
-
}));
|
|
33
|
-
// Type the mocked functions
|
|
34
|
-
const mockFormatRecipientsForSplitV2 = formatRecipientsForSplitV2;
|
|
35
|
-
const mockPredictSplitV2Address = predictSplitV2Address;
|
|
36
|
-
const mockIsSplitV2Deployed = isSplitV2Deployed;
|
|
37
|
-
const mockDeployOVMAndSplitV2 = deployOVMAndSplitV2;
|
|
38
|
-
const mockDeployOVMContract = deployOVMContract;
|
|
39
|
-
const mockRequestWithdrawalFromOVM = requestWithdrawalFromOVM;
|
|
40
|
-
const mockdepositWithMulticall3 = depositWithMulticall3;
|
|
41
|
-
const mockIsContractAvailable = isContractAvailable;
|
|
42
|
-
describe('ObolSplits', () => {
|
|
43
|
-
let client;
|
|
44
|
-
let mockSigner;
|
|
45
|
-
let mockProvider;
|
|
46
|
-
beforeEach(() => {
|
|
47
|
-
// Clear all mocks before each test
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
// Reset the mock to not be called by default
|
|
50
|
-
mockRequestWithdrawalFromOVM.mockReset();
|
|
51
|
-
mockSigner = {
|
|
52
|
-
getAddress: jest
|
|
53
|
-
.fn()
|
|
54
|
-
.mockResolvedValue('0x1234567890123456789012345678901234567890'),
|
|
55
|
-
signTypedData: jest.fn().mockResolvedValue('0xsigned'),
|
|
56
|
-
provider: {
|
|
57
|
-
getCode: jest.fn().mockResolvedValue('0x123456'),
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
mockProvider = {
|
|
61
|
-
getCode: jest.fn().mockResolvedValue('0x123456'),
|
|
62
|
-
};
|
|
63
|
-
client = new Client({ chainId: 1 }, mockSigner, mockProvider);
|
|
64
|
-
});
|
|
65
|
-
describe('createValidatorManagerAndRewardsSplit', () => {
|
|
66
|
-
const mockRewardsSplitPayload = {
|
|
67
|
-
rewardSplitRecipients: [
|
|
68
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
69
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
70
|
-
],
|
|
71
|
-
OVMOwnerAddress: TEST_ADDRESSES.OVM_OWNER,
|
|
72
|
-
splitOwnerAddress: TEST_ADDRESSES.SPLIT_OWNER,
|
|
73
|
-
principalRecipient: TEST_ADDRESSES.PRINCIPAL_RECIPIENT,
|
|
74
|
-
distributorFeePercent: 0,
|
|
75
|
-
};
|
|
76
|
-
it('should create rewards-only split successfully', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
-
// Mock helper functions
|
|
78
|
-
mockFormatRecipientsForSplitV2.mockReturnValue([
|
|
79
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
80
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
81
|
-
{
|
|
82
|
-
address: '0xDe5aE4De36c966747Ea7DF13BD9589642e2B1D0d',
|
|
83
|
-
percentAllocation: 1,
|
|
84
|
-
},
|
|
85
|
-
]);
|
|
86
|
-
mockPredictSplitV2Address.mockResolvedValue('0xRewardsSplitAddress');
|
|
87
|
-
mockIsSplitV2Deployed.mockResolvedValue(false);
|
|
88
|
-
mockDeployOVMAndSplitV2.mockResolvedValue('0xOVMAddress');
|
|
89
|
-
mockIsContractAvailable.mockResolvedValue(true);
|
|
90
|
-
const result = yield client.splits.createValidatorManagerAndRewardsSplit(mockRewardsSplitPayload);
|
|
91
|
-
expect(result).toEqual({
|
|
92
|
-
withdrawal_address: '0xOVMAddress',
|
|
93
|
-
fee_recipient_address: '0xRewardsSplitAddress',
|
|
94
|
-
});
|
|
95
|
-
expect(mockFormatRecipientsForSplitV2).toHaveBeenCalled();
|
|
96
|
-
expect(mockPredictSplitV2Address).toHaveBeenCalled();
|
|
97
|
-
expect(mockIsSplitV2Deployed).toHaveBeenCalled();
|
|
98
|
-
expect(mockDeployOVMAndSplitV2).toHaveBeenCalled();
|
|
99
|
-
}));
|
|
100
|
-
it('should throw error when signer is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
-
const clientWithoutSigner = new Client({ chainId: 1 }, undefined, mockProvider);
|
|
102
|
-
yield expect(clientWithoutSigner.splits.createValidatorManagerAndRewardsSplit(mockRewardsSplitPayload)).rejects.toThrow('Signer is required in createValidatorManagerAndRewardsSplit');
|
|
103
|
-
}));
|
|
104
|
-
it('should throw error when chain is not supported', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
-
const clientUnsupportedChain = new Client({ chainId: 999 }, mockSigner, mockProvider);
|
|
106
|
-
yield expect(clientUnsupportedChain.splits.createValidatorManagerAndRewardsSplit(mockRewardsSplitPayload)).rejects.toThrow('Splitter configuration is not supported on 999 chain');
|
|
107
|
-
}));
|
|
108
|
-
it('should throw error when OVM factory is not configured', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
-
// Mock chain configuration without OVM factory
|
|
110
|
-
const originalConfig = CHAIN_CONFIGURATION[1];
|
|
111
|
-
// Create a new config object without OVM_FACTORY_CONTRACT
|
|
112
|
-
const configWithoutOVM = Object.assign({}, originalConfig);
|
|
113
|
-
delete configWithoutOVM.OVM_FACTORY_CONTRACT;
|
|
114
|
-
CHAIN_CONFIGURATION[1] = configWithoutOVM;
|
|
115
|
-
yield expect(client.splits.createValidatorManagerAndRewardsSplit(mockRewardsSplitPayload)).rejects.toThrow('OVM contract factory is not configured for chain 1');
|
|
116
|
-
// Restore original config
|
|
117
|
-
CHAIN_CONFIGURATION[1] = originalConfig;
|
|
118
|
-
}));
|
|
119
|
-
});
|
|
120
|
-
describe('createValidatorManagerAndTotalSplit', () => {
|
|
121
|
-
const mockTotalSplitPayload = {
|
|
122
|
-
rewardSplitRecipients: [
|
|
123
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
124
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
125
|
-
],
|
|
126
|
-
principalSplitRecipients: [
|
|
127
|
-
{
|
|
128
|
-
address: TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
129
|
-
percentAllocation: 60,
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
address: TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
133
|
-
percentAllocation: 40,
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
OVMOwnerAddress: TEST_ADDRESSES.OVM_OWNER,
|
|
137
|
-
splitOwnerAddress: TEST_ADDRESSES.SPLIT_OWNER,
|
|
138
|
-
distributorFeePercent: 0,
|
|
139
|
-
};
|
|
140
|
-
it('should create total split successfully', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
-
// Mock helper functions
|
|
142
|
-
mockFormatRecipientsForSplitV2
|
|
143
|
-
.mockReturnValueOnce([
|
|
144
|
-
// rewards recipients
|
|
145
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
146
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
147
|
-
{
|
|
148
|
-
address: '0xDe5aE4De36c966747Ea7DF13BD9589642e2B1D0d',
|
|
149
|
-
percentAllocation: 1,
|
|
150
|
-
},
|
|
151
|
-
])
|
|
152
|
-
.mockReturnValueOnce([
|
|
153
|
-
// principal recipients
|
|
154
|
-
{
|
|
155
|
-
address: TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
156
|
-
percentAllocation: 60,
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
address: TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
160
|
-
percentAllocation: 40,
|
|
161
|
-
},
|
|
162
|
-
]);
|
|
163
|
-
mockPredictSplitV2Address
|
|
164
|
-
.mockResolvedValueOnce('0xRewardsSplitAddress')
|
|
165
|
-
.mockResolvedValueOnce('0xPrincipalSplitAddress');
|
|
166
|
-
mockIsSplitV2Deployed
|
|
167
|
-
.mockResolvedValueOnce(false) // rewards split not deployed
|
|
168
|
-
.mockResolvedValueOnce(false); // principal split not deployed
|
|
169
|
-
mockDeployOVMAndSplitV2.mockResolvedValue('0xOVMAddress');
|
|
170
|
-
mockIsContractAvailable.mockResolvedValue(true);
|
|
171
|
-
const result = yield client.splits.createValidatorManagerAndTotalSplit(mockTotalSplitPayload);
|
|
172
|
-
expect(result).toEqual({
|
|
173
|
-
withdrawal_address: '0xOVMAddress',
|
|
174
|
-
fee_recipient_address: '0xRewardsSplitAddress',
|
|
175
|
-
});
|
|
176
|
-
expect(mockFormatRecipientsForSplitV2).toHaveBeenCalledTimes(2);
|
|
177
|
-
expect(mockPredictSplitV2Address).toHaveBeenCalledTimes(2);
|
|
178
|
-
expect(mockIsSplitV2Deployed).toHaveBeenCalledTimes(2);
|
|
179
|
-
expect(mockDeployOVMAndSplitV2).toHaveBeenCalled();
|
|
180
|
-
}));
|
|
181
|
-
it('should handle case when both splits are already deployed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
182
|
-
// Mock helper functions
|
|
183
|
-
mockFormatRecipientsForSplitV2
|
|
184
|
-
.mockReturnValueOnce([
|
|
185
|
-
// rewards recipients
|
|
186
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
187
|
-
{ address: TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
188
|
-
{
|
|
189
|
-
address: '0xDe5aE4De36c966747Ea7DF13BD9589642e2B1D0d',
|
|
190
|
-
percentAllocation: 1,
|
|
191
|
-
},
|
|
192
|
-
])
|
|
193
|
-
.mockReturnValueOnce([
|
|
194
|
-
// principal recipients
|
|
195
|
-
{
|
|
196
|
-
address: TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
197
|
-
percentAllocation: 60,
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
address: TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
201
|
-
percentAllocation: 40,
|
|
202
|
-
},
|
|
203
|
-
]);
|
|
204
|
-
mockPredictSplitV2Address
|
|
205
|
-
.mockResolvedValueOnce('0xRewardsSplitAddress')
|
|
206
|
-
.mockResolvedValueOnce('0xPrincipalSplitAddress');
|
|
207
|
-
mockIsSplitV2Deployed
|
|
208
|
-
.mockResolvedValueOnce(true) // rewards split deployed
|
|
209
|
-
.mockResolvedValueOnce(true); // principal split deployed
|
|
210
|
-
mockDeployOVMContract.mockResolvedValue('0xOVMAddress');
|
|
211
|
-
mockIsContractAvailable.mockResolvedValue(true);
|
|
212
|
-
const result = yield client.splits.createValidatorManagerAndTotalSplit(mockTotalSplitPayload);
|
|
213
|
-
expect(result).toEqual({
|
|
214
|
-
withdrawal_address: '0xOVMAddress',
|
|
215
|
-
fee_recipient_address: '0xRewardsSplitAddress',
|
|
216
|
-
});
|
|
217
|
-
expect(mockDeployOVMContract).toHaveBeenCalledWith({
|
|
218
|
-
OVMOwnerAddress: mockTotalSplitPayload.OVMOwnerAddress,
|
|
219
|
-
principalRecipient: '0xPrincipalSplitAddress',
|
|
220
|
-
rewardRecipient: '0xRewardsSplitAddress',
|
|
221
|
-
principalThreshold: mockTotalSplitPayload.principalThreshold,
|
|
222
|
-
signer: mockSigner,
|
|
223
|
-
chainId: 1,
|
|
224
|
-
});
|
|
225
|
-
}));
|
|
226
|
-
it('should throw error when signer is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
227
|
-
const clientWithoutSigner = new Client({ chainId: 1 }, undefined, mockProvider);
|
|
228
|
-
yield expect(clientWithoutSigner.splits.createValidatorManagerAndTotalSplit(mockTotalSplitPayload)).rejects.toThrow('Signer is required in createValidatorManagerAndTotalSplit');
|
|
229
|
-
}));
|
|
230
|
-
it('should throw error when chain is not supported', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
231
|
-
const clientUnsupportedChain = new Client({ chainId: 999 }, mockSigner, mockProvider);
|
|
232
|
-
yield expect(clientUnsupportedChain.splits.createValidatorManagerAndTotalSplit(mockTotalSplitPayload)).rejects.toThrow('Splitter configuration is not supported on 999 chain');
|
|
233
|
-
}));
|
|
234
|
-
});
|
|
235
|
-
describe('requestWithdrawal', () => {
|
|
236
|
-
const mockOVMAddress = '0x1234567890123456789012345678901234567890';
|
|
237
|
-
const mockPubKeys = [
|
|
238
|
-
'0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
|
|
239
|
-
];
|
|
240
|
-
const mockAmounts = ['32000000000']; // 32 ETH in gwei
|
|
241
|
-
it('should request withdrawal successfully', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
242
|
-
mockRequestWithdrawalFromOVM.mockResolvedValue({
|
|
243
|
-
txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
244
|
-
});
|
|
245
|
-
const result = yield client.splits.requestWithdrawal({
|
|
246
|
-
ovmAddress: mockOVMAddress,
|
|
247
|
-
pubKeys: mockPubKeys,
|
|
248
|
-
amounts: mockAmounts,
|
|
249
|
-
withdrawalFees: '1',
|
|
250
|
-
});
|
|
251
|
-
expect(result).toEqual({
|
|
252
|
-
txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
253
|
-
});
|
|
254
|
-
expect(mockRequestWithdrawalFromOVM).toHaveBeenCalledWith({
|
|
255
|
-
ovmAddress: mockOVMAddress,
|
|
256
|
-
pubKeys: mockPubKeys,
|
|
257
|
-
amounts: mockAmounts,
|
|
258
|
-
withdrawalFees: '1',
|
|
259
|
-
signer: mockSigner,
|
|
260
|
-
});
|
|
261
|
-
}));
|
|
262
|
-
it('should throw error when signer is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
263
|
-
const clientWithoutSigner = new Client({ chainId: 1 }, undefined, mockProvider);
|
|
264
|
-
yield expect(clientWithoutSigner.splits.requestWithdrawal({
|
|
265
|
-
ovmAddress: mockOVMAddress,
|
|
266
|
-
pubKeys: mockPubKeys,
|
|
267
|
-
amounts: mockAmounts,
|
|
268
|
-
withdrawalFees: '1',
|
|
269
|
-
})).rejects.toThrow('Signer is required in requestWithdrawal');
|
|
270
|
-
}));
|
|
271
|
-
// it('should throw error when amount is below minimum (1,000,000 gwei)', async () => {
|
|
272
|
-
// await expect(
|
|
273
|
-
// client.splits.requestWithdrawal({
|
|
274
|
-
// ovmAddress: mockOVMAddress,
|
|
275
|
-
// pubKeys: mockPubKeys,
|
|
276
|
-
// amounts: ['500000'], // Below minimum of 1,000,000 gwei
|
|
277
|
-
// }),
|
|
278
|
-
// ).rejects.toThrow('Validation failed');
|
|
279
|
-
// });
|
|
280
|
-
it('should handle multiple validators withdrawal request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
281
|
-
const multiplePubKeys = [
|
|
282
|
-
'0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
|
|
283
|
-
'0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
|
|
284
|
-
];
|
|
285
|
-
const multipleAmounts = [
|
|
286
|
-
'32000000000', // 32 ETH
|
|
287
|
-
'16000000000', // 16 ETH
|
|
288
|
-
];
|
|
289
|
-
mockRequestWithdrawalFromOVM.mockResolvedValue({
|
|
290
|
-
txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
291
|
-
});
|
|
292
|
-
const result = yield client.splits.requestWithdrawal({
|
|
293
|
-
ovmAddress: mockOVMAddress,
|
|
294
|
-
pubKeys: multiplePubKeys,
|
|
295
|
-
amounts: multipleAmounts,
|
|
296
|
-
withdrawalFees: '1',
|
|
297
|
-
});
|
|
298
|
-
expect(result).toEqual({
|
|
299
|
-
txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
300
|
-
});
|
|
301
|
-
expect(mockRequestWithdrawalFromOVM).toHaveBeenCalledWith({
|
|
302
|
-
ovmAddress: mockOVMAddress,
|
|
303
|
-
pubKeys: multiplePubKeys,
|
|
304
|
-
amounts: multipleAmounts,
|
|
305
|
-
withdrawalFees: '1',
|
|
306
|
-
signer: mockSigner,
|
|
307
|
-
});
|
|
308
|
-
}));
|
|
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
|
-
});
|
|
392
|
-
describe('constructor', () => {
|
|
393
|
-
it('should create Client instance with splits property', () => {
|
|
394
|
-
const testClient = new Client({ chainId: 1 }, mockSigner, mockProvider);
|
|
395
|
-
expect(testClient.splits).toBeDefined();
|
|
396
|
-
expect(testClient.splits.chainId).toBe(1);
|
|
397
|
-
expect(testClient.splits.provider).toBe(mockProvider);
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
});
|