@obolnetwork/obol-sdk 2.2.0 → 2.2.1
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/verification/common.js +3 -3
- package/dist/cjs/test/methods.test.js +64 -54
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/verification/common.js +3 -3
- package/dist/esm/test/methods.test.js +64 -54
- package/package.json +1 -1
- package/src/verification/common.ts +5 -3
package/dist/cjs/package.json
CHANGED
|
@@ -162,14 +162,14 @@ const verifyDefinitionSignatures = (clusterDefinition, definitionType) => __awai
|
|
|
162
162
|
if (definitionType === constants_js_1.DefinitionFlow.Solo) {
|
|
163
163
|
return true;
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
for (const operator of clusterDefinition.operators) {
|
|
166
166
|
const isPUTConfigHashSignerValid = yield validatePUTConfigHashSigner(operator.address, operator.config_signature, clusterDefinition.config_hash, types_js_1.FORK_MAPPING[clusterDefinition.fork_version]);
|
|
167
167
|
const isENRSignerValid = yield validateEnrSigner(operator.address, operator.enr_signature, operator.enr, types_js_1.FORK_MAPPING[clusterDefinition.fork_version]);
|
|
168
168
|
if (!isPUTConfigHashSignerValid || !isENRSignerValid) {
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
// cluster-lock data verification
|
|
@@ -43,6 +43,7 @@ const node_1 = require("msw/node");
|
|
|
43
43
|
const termsAndConditions_1 = require("../src/verification/termsAndConditions");
|
|
44
44
|
const utils = __importStar(require("../src/utils"));
|
|
45
45
|
const splitsHelpers = __importStar(require("../src/splitHelpers"));
|
|
46
|
+
jest.setTimeout(20000);
|
|
46
47
|
/* eslint no-new: 0 */
|
|
47
48
|
describe('Cluster Client', () => {
|
|
48
49
|
var _a, _b;
|
|
@@ -161,6 +162,9 @@ describe('Cluster Client without a signer', () => {
|
|
|
161
162
|
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
162
163
|
chainId: 17000,
|
|
163
164
|
});
|
|
165
|
+
beforeAll(() => {
|
|
166
|
+
jest.restoreAllMocks();
|
|
167
|
+
});
|
|
164
168
|
test('createClusterDefinition should throw an error without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
169
|
try {
|
|
166
170
|
yield clientInstance.createClusterDefinition(fixtures_js_1.clusterConfigV1X8);
|
|
@@ -224,37 +228,40 @@ describe('Cluster Client without a signer', () => {
|
|
|
224
228
|
}));
|
|
225
229
|
});
|
|
226
230
|
describe('createObolRewardsSplit', () => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
231
|
+
let clientInstance, clientInstanceWithourSigner, mockSplitRecipients, mockPrincipalRecipient, mockEtherAmount, mockSigner;
|
|
232
|
+
beforeAll(() => {
|
|
233
|
+
var _a, _b;
|
|
234
|
+
jest
|
|
235
|
+
.spyOn(utils, 'isContractAvailable')
|
|
236
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
237
|
+
jest
|
|
238
|
+
.spyOn(splitsHelpers, 'predictSplitterAddress')
|
|
239
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xPredictedAddress'); }));
|
|
240
|
+
jest.spyOn(splitsHelpers, 'handleDeployOWRAndSplitter').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
241
|
+
return yield Promise.resolve({
|
|
242
|
+
withdrawal_address: '0xWithdrawalAddress',
|
|
243
|
+
fee_recipient_address: '0xFeeRecipientAddress',
|
|
244
|
+
});
|
|
245
|
+
}));
|
|
246
|
+
const mnemonic = (_b = (_a = ethers_1.ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
|
|
247
|
+
const privateKey = ethers_1.ethers.Wallet.fromPhrase(mnemonic).privateKey;
|
|
248
|
+
const provider = new ethers_1.JsonRpcProvider('https://ethereum-holesky.publicnode.com');
|
|
249
|
+
const wallet = new ethers_1.ethers.Wallet(privateKey, provider);
|
|
250
|
+
mockSigner = wallet.connect(provider);
|
|
251
|
+
clientInstance = new index_1.Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
|
|
252
|
+
clientInstanceWithourSigner = new index_1.Client({
|
|
253
|
+
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
254
|
+
chainId: 17000,
|
|
238
255
|
});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
248
|
-
chainId: 17000,
|
|
256
|
+
mockSplitRecipients = [
|
|
257
|
+
{
|
|
258
|
+
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
259
|
+
percentAllocation: 99,
|
|
260
|
+
},
|
|
261
|
+
];
|
|
262
|
+
mockPrincipalRecipient = '0x86B8145c98e5BD25BA722645b15eD65f024a87EC';
|
|
263
|
+
mockEtherAmount = 64;
|
|
249
264
|
});
|
|
250
|
-
const mockSplitRecipients = [
|
|
251
|
-
{
|
|
252
|
-
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
253
|
-
percentAllocation: 99,
|
|
254
|
-
},
|
|
255
|
-
];
|
|
256
|
-
const mockPrincipalRecipient = '0x86B8145c98e5BD25BA722645b15eD65f024a87EC';
|
|
257
|
-
const mockEtherAmount = 64;
|
|
258
265
|
it('should throw an error if signer is not defined', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
259
266
|
yield expect(clientInstanceWithourSigner.createObolRewardsSplit({
|
|
260
267
|
splitRecipients: mockSplitRecipients,
|
|
@@ -318,32 +325,35 @@ describe('createObolRewardsSplit', () => {
|
|
|
318
325
|
}));
|
|
319
326
|
});
|
|
320
327
|
describe('createObolTotalSplit', () => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
339
|
-
|
|
328
|
+
let clientInstanceWithourSigner, mockSplitRecipients, mockSigner, clientInstance;
|
|
329
|
+
beforeAll(() => {
|
|
330
|
+
var _a, _b;
|
|
331
|
+
jest
|
|
332
|
+
.spyOn(utils, 'isContractAvailable')
|
|
333
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
334
|
+
jest
|
|
335
|
+
.spyOn(splitsHelpers, 'predictSplitterAddress')
|
|
336
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xPredictedAddress'); }));
|
|
337
|
+
jest
|
|
338
|
+
.spyOn(splitsHelpers, 'deploySplitterContract')
|
|
339
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xSplitterAddress'); }));
|
|
340
|
+
const mnemonic = (_b = (_a = ethers_1.ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
|
|
341
|
+
const privateKey = ethers_1.ethers.Wallet.fromPhrase(mnemonic).privateKey;
|
|
342
|
+
const provider = new ethers_1.JsonRpcProvider('https://ethereum-holesky.publicnode.com');
|
|
343
|
+
const wallet = new ethers_1.ethers.Wallet(privateKey, provider);
|
|
344
|
+
mockSigner = wallet.connect(provider);
|
|
345
|
+
clientInstance = new index_1.Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
|
|
346
|
+
clientInstanceWithourSigner = new index_1.Client({
|
|
347
|
+
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
348
|
+
chainId: 17000,
|
|
349
|
+
});
|
|
350
|
+
mockSplitRecipients = [
|
|
351
|
+
{
|
|
352
|
+
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
353
|
+
percentAllocation: 99.9,
|
|
354
|
+
},
|
|
355
|
+
];
|
|
340
356
|
});
|
|
341
|
-
const mockSplitRecipients = [
|
|
342
|
-
{
|
|
343
|
-
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
344
|
-
percentAllocation: 99.9,
|
|
345
|
-
},
|
|
346
|
-
];
|
|
347
357
|
it('should throw an error if signer is not defined', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
348
358
|
yield expect(clientInstanceWithourSigner.createObolTotalSplit({
|
|
349
359
|
splitRecipients: mockSplitRecipients,
|
package/dist/esm/package.json
CHANGED
|
@@ -131,14 +131,14 @@ const verifyDefinitionSignatures = (clusterDefinition, definitionType) => __awai
|
|
|
131
131
|
if (definitionType === DefinitionFlow.Solo) {
|
|
132
132
|
return true;
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
for (const operator of clusterDefinition.operators) {
|
|
135
135
|
const isPUTConfigHashSignerValid = yield validatePUTConfigHashSigner(operator.address, operator.config_signature, clusterDefinition.config_hash, FORK_MAPPING[clusterDefinition.fork_version]);
|
|
136
136
|
const isENRSignerValid = yield validateEnrSigner(operator.address, operator.enr_signature, operator.enr, FORK_MAPPING[clusterDefinition.fork_version]);
|
|
137
137
|
if (!isPUTConfigHashSignerValid || !isENRSignerValid) {
|
|
138
138
|
return false;
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
// cluster-lock data verification
|
|
@@ -18,6 +18,7 @@ import { setupServer } from 'msw/node';
|
|
|
18
18
|
import { hashTermsAndConditions } from '../src/verification/termsAndConditions';
|
|
19
19
|
import * as utils from '../src/utils';
|
|
20
20
|
import * as splitsHelpers from '../src/splitHelpers';
|
|
21
|
+
jest.setTimeout(20000);
|
|
21
22
|
/* eslint no-new: 0 */
|
|
22
23
|
describe('Cluster Client', () => {
|
|
23
24
|
var _a, _b;
|
|
@@ -136,6 +137,9 @@ describe('Cluster Client without a signer', () => {
|
|
|
136
137
|
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
137
138
|
chainId: 17000,
|
|
138
139
|
});
|
|
140
|
+
beforeAll(() => {
|
|
141
|
+
jest.restoreAllMocks();
|
|
142
|
+
});
|
|
139
143
|
test('createClusterDefinition should throw an error without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
144
|
try {
|
|
141
145
|
yield clientInstance.createClusterDefinition(clusterConfigV1X8);
|
|
@@ -199,37 +203,40 @@ describe('Cluster Client without a signer', () => {
|
|
|
199
203
|
}));
|
|
200
204
|
});
|
|
201
205
|
describe('createObolRewardsSplit', () => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
206
|
+
let clientInstance, clientInstanceWithourSigner, mockSplitRecipients, mockPrincipalRecipient, mockEtherAmount, mockSigner;
|
|
207
|
+
beforeAll(() => {
|
|
208
|
+
var _a, _b;
|
|
209
|
+
jest
|
|
210
|
+
.spyOn(utils, 'isContractAvailable')
|
|
211
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
212
|
+
jest
|
|
213
|
+
.spyOn(splitsHelpers, 'predictSplitterAddress')
|
|
214
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xPredictedAddress'); }));
|
|
215
|
+
jest.spyOn(splitsHelpers, 'handleDeployOWRAndSplitter').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
216
|
+
return yield Promise.resolve({
|
|
217
|
+
withdrawal_address: '0xWithdrawalAddress',
|
|
218
|
+
fee_recipient_address: '0xFeeRecipientAddress',
|
|
219
|
+
});
|
|
220
|
+
}));
|
|
221
|
+
const mnemonic = (_b = (_a = ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
|
|
222
|
+
const privateKey = ethers.Wallet.fromPhrase(mnemonic).privateKey;
|
|
223
|
+
const provider = new JsonRpcProvider('https://ethereum-holesky.publicnode.com');
|
|
224
|
+
const wallet = new ethers.Wallet(privateKey, provider);
|
|
225
|
+
mockSigner = wallet.connect(provider);
|
|
226
|
+
clientInstance = new Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
|
|
227
|
+
clientInstanceWithourSigner = new Client({
|
|
228
|
+
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
229
|
+
chainId: 17000,
|
|
213
230
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
223
|
-
chainId: 17000,
|
|
231
|
+
mockSplitRecipients = [
|
|
232
|
+
{
|
|
233
|
+
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
234
|
+
percentAllocation: 99,
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
mockPrincipalRecipient = '0x86B8145c98e5BD25BA722645b15eD65f024a87EC';
|
|
238
|
+
mockEtherAmount = 64;
|
|
224
239
|
});
|
|
225
|
-
const mockSplitRecipients = [
|
|
226
|
-
{
|
|
227
|
-
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
228
|
-
percentAllocation: 99,
|
|
229
|
-
},
|
|
230
|
-
];
|
|
231
|
-
const mockPrincipalRecipient = '0x86B8145c98e5BD25BA722645b15eD65f024a87EC';
|
|
232
|
-
const mockEtherAmount = 64;
|
|
233
240
|
it('should throw an error if signer is not defined', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
234
241
|
yield expect(clientInstanceWithourSigner.createObolRewardsSplit({
|
|
235
242
|
splitRecipients: mockSplitRecipients,
|
|
@@ -293,32 +300,35 @@ describe('createObolRewardsSplit', () => {
|
|
|
293
300
|
}));
|
|
294
301
|
});
|
|
295
302
|
describe('createObolTotalSplit', () => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
314
|
-
|
|
303
|
+
let clientInstanceWithourSigner, mockSplitRecipients, mockSigner, clientInstance;
|
|
304
|
+
beforeAll(() => {
|
|
305
|
+
var _a, _b;
|
|
306
|
+
jest
|
|
307
|
+
.spyOn(utils, 'isContractAvailable')
|
|
308
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
|
|
309
|
+
jest
|
|
310
|
+
.spyOn(splitsHelpers, 'predictSplitterAddress')
|
|
311
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xPredictedAddress'); }));
|
|
312
|
+
jest
|
|
313
|
+
.spyOn(splitsHelpers, 'deploySplitterContract')
|
|
314
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xSplitterAddress'); }));
|
|
315
|
+
const mnemonic = (_b = (_a = ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
|
|
316
|
+
const privateKey = ethers.Wallet.fromPhrase(mnemonic).privateKey;
|
|
317
|
+
const provider = new JsonRpcProvider('https://ethereum-holesky.publicnode.com');
|
|
318
|
+
const wallet = new ethers.Wallet(privateKey, provider);
|
|
319
|
+
mockSigner = wallet.connect(provider);
|
|
320
|
+
clientInstance = new Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
|
|
321
|
+
clientInstanceWithourSigner = new Client({
|
|
322
|
+
baseUrl: 'https://obol-api-dev.gcp.obol.tech',
|
|
323
|
+
chainId: 17000,
|
|
324
|
+
});
|
|
325
|
+
mockSplitRecipients = [
|
|
326
|
+
{
|
|
327
|
+
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
328
|
+
percentAllocation: 99.9,
|
|
329
|
+
},
|
|
330
|
+
];
|
|
315
331
|
});
|
|
316
|
-
const mockSplitRecipients = [
|
|
317
|
-
{
|
|
318
|
-
account: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
319
|
-
percentAllocation: 99.9,
|
|
320
|
-
},
|
|
321
|
-
];
|
|
322
332
|
it('should throw an error if signer is not defined', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
323
333
|
yield expect(clientInstanceWithourSigner.createObolTotalSplit({
|
|
324
334
|
splitRecipients: mockSplitRecipients,
|
package/package.json
CHANGED
|
@@ -216,7 +216,8 @@ const verifyDefinitionSignatures = async (
|
|
|
216
216
|
if (definitionType === DefinitionFlow.Solo) {
|
|
217
217
|
return true;
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
|
|
220
|
+
for (const operator of clusterDefinition.operators) {
|
|
220
221
|
const isPUTConfigHashSignerValid = await validatePUTConfigHashSigner(
|
|
221
222
|
operator.address,
|
|
222
223
|
operator.config_signature as string,
|
|
@@ -238,8 +239,9 @@ const verifyDefinitionSignatures = async (
|
|
|
238
239
|
if (!isPUTConfigHashSignerValid || !isENRSignerValid) {
|
|
239
240
|
return false;
|
|
240
241
|
}
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return true;
|
|
243
245
|
}
|
|
244
246
|
};
|
|
245
247
|
|