@obolnetwork/obol-sdk 2.9.0 → 2.9.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
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"
@@ -68,7 +68,6 @@ const validateOVMTotalSplitRecipients = (_, data) => {
68
68
  return validateTotalPercentage(splitPercentage);
69
69
  };
70
70
  const validateOVMRequestWithdrawalPayload = (_, data) => {
71
- console.log(data, 'hanaaan dataaaa');
72
71
  if (!data.pubKeys || !data.amounts) {
73
72
  return false;
74
73
  }
@@ -212,6 +212,10 @@ exports.ovmTotalSplitPayloadSchema = {
212
212
  exports.ovmRequestWithdrawalPayloadSchema = {
213
213
  type: 'object',
214
214
  properties: {
215
+ withdrawalFees: {
216
+ type: 'string',
217
+ pattern: '^[0-9]+$',
218
+ },
215
219
  ovmAddress: {
216
220
  type: 'string',
217
221
  pattern: '^0x[a-fA-F0-9]{40}$',
@@ -234,5 +238,5 @@ exports.ovmRequestWithdrawalPayloadSchema = {
234
238
  },
235
239
  },
236
240
  validateOVMRequestWithdrawalPayload: true,
237
- required: ['ovmAddress', 'pubKeys', 'amounts'],
241
+ required: ['ovmAddress', 'pubKeys', 'amounts', 'withdrawalFees'],
238
242
  };
@@ -507,13 +507,15 @@ const getChainConfig = (chainId) => {
507
507
  * @param signer - The signer to use for the transaction
508
508
  * @returns Promise that resolves to the transaction hash
509
509
  */
510
- const requestWithdrawalFromOVM = ({ ovmAddress, pubKeys, amounts, signer, }) => __awaiter(void 0, void 0, void 0, function* () {
510
+ const requestWithdrawalFromOVM = ({ ovmAddress, pubKeys, amounts, withdrawalFees, signer, }) => __awaiter(void 0, void 0, void 0, function* () {
511
511
  var _15;
512
512
  try {
513
513
  // Convert string amounts to bigint
514
514
  const bigintAmounts = amounts.map(amount => BigInt(amount));
515
515
  const ovmContract = new ethers_1.Contract(ovmAddress, OVMFactory_1.OVMContract.abi, signer);
516
- const tx = yield ovmContract.requestWithdrawal(pubKeys, bigintAmounts);
516
+ const tx = yield ovmContract.requestWithdrawal(pubKeys, bigintAmounts, {
517
+ value: BigInt(withdrawalFees),
518
+ });
517
519
  const receipt = yield tx.wait();
518
520
  return { txHash: receipt.hash };
519
521
  }
@@ -314,6 +314,7 @@ class ObolSplits {
314
314
  ovmAddress: validatedPayload.ovmAddress,
315
315
  pubKeys: validatedPayload.pubKeys,
316
316
  amounts: validatedPayload.amounts,
317
+ withdrawalFees: validatedPayload.withdrawalFees,
317
318
  signer: this.signer,
318
319
  });
319
320
  });
@@ -274,6 +274,7 @@ describe('ovmRequestWithdrawalPayloadSchema', () => {
274
274
  '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
275
275
  ],
276
276
  amounts: ['32000000000'],
277
+ withdrawalFees: '1',
277
278
  };
278
279
  it('should throw error when OVM address is missing', () => {
279
280
  const payload = {
@@ -288,14 +289,32 @@ describe('ovmRequestWithdrawalPayloadSchema', () => {
288
289
  pubKeys: validPayload.pubKeys,
289
290
  amounts: validPayload.amounts,
290
291
  };
291
- expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: /ovmAddress must match pattern');
292
+ expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: must have required property \'withdrawalFees\', /ovmAddress must match pattern "^0x[a-fA-F0-9]{40}$"');
292
293
  });
293
294
  it('should throw error when number of public keys does not match number of amounts', () => {
294
295
  const payload = {
295
296
  ovmAddress: validPayload.ovmAddress,
296
297
  pubKeys: validPayload.pubKeys,
297
298
  amounts: ['32000000000', '16000000000'], // 2 amounts, 1 pubKey
299
+ withdrawalFees: validPayload.withdrawalFees,
298
300
  };
299
301
  expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: must pass "validateOVMRequestWithdrawalPayload" keyword validation');
300
302
  });
303
+ it('should throw error when withdrawalFees is missing', () => {
304
+ const payload = {
305
+ ovmAddress: validPayload.ovmAddress,
306
+ pubKeys: validPayload.pubKeys,
307
+ amounts: validPayload.amounts,
308
+ };
309
+ expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow("Validation failed: must have required property 'withdrawalFees'");
310
+ });
311
+ it('should throw error when withdrawalFees is invalid', () => {
312
+ const payload = {
313
+ ovmAddress: validPayload.ovmAddress,
314
+ pubKeys: validPayload.pubKeys,
315
+ amounts: validPayload.amounts,
316
+ withdrawalFees: 'invalid',
317
+ };
318
+ expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: /withdrawalFees must match pattern "^[0-9]+$"');
319
+ });
301
320
  });
@@ -246,6 +246,7 @@ describe('ObolSplits', () => {
246
246
  ovmAddress: mockOVMAddress,
247
247
  pubKeys: mockPubKeys,
248
248
  amounts: mockAmounts,
249
+ withdrawalFees: '1',
249
250
  });
250
251
  expect(result).toEqual({
251
252
  txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
@@ -254,6 +255,7 @@ describe('ObolSplits', () => {
254
255
  ovmAddress: mockOVMAddress,
255
256
  pubKeys: mockPubKeys,
256
257
  amounts: mockAmounts,
258
+ withdrawalFees: '1',
257
259
  signer: mockSigner,
258
260
  });
259
261
  }));
@@ -263,6 +265,7 @@ describe('ObolSplits', () => {
263
265
  ovmAddress: mockOVMAddress,
264
266
  pubKeys: mockPubKeys,
265
267
  amounts: mockAmounts,
268
+ withdrawalFees: '1',
266
269
  })).rejects.toThrow('Signer is required in requestWithdrawal');
267
270
  }));
268
271
  // it('should throw error when amount is below minimum (1,000,000 gwei)', async () => {
@@ -290,6 +293,7 @@ describe('ObolSplits', () => {
290
293
  ovmAddress: mockOVMAddress,
291
294
  pubKeys: multiplePubKeys,
292
295
  amounts: multipleAmounts,
296
+ withdrawalFees: '1',
293
297
  });
294
298
  expect(result).toEqual({
295
299
  txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
@@ -298,6 +302,7 @@ describe('ObolSplits', () => {
298
302
  ovmAddress: mockOVMAddress,
299
303
  pubKeys: multiplePubKeys,
300
304
  amounts: multipleAmounts,
305
+ withdrawalFees: '1',
301
306
  signer: mockSigner,
302
307
  });
303
308
  }));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
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"
@@ -62,7 +62,6 @@ const validateOVMTotalSplitRecipients = (_, data) => {
62
62
  return validateTotalPercentage(splitPercentage);
63
63
  };
64
64
  const validateOVMRequestWithdrawalPayload = (_, data) => {
65
- console.log(data, 'hanaaan dataaaa');
66
65
  if (!data.pubKeys || !data.amounts) {
67
66
  return false;
68
67
  }
@@ -209,6 +209,10 @@ export const ovmTotalSplitPayloadSchema = {
209
209
  export const ovmRequestWithdrawalPayloadSchema = {
210
210
  type: 'object',
211
211
  properties: {
212
+ withdrawalFees: {
213
+ type: 'string',
214
+ pattern: '^[0-9]+$',
215
+ },
212
216
  ovmAddress: {
213
217
  type: 'string',
214
218
  pattern: '^0x[a-fA-F0-9]{40}$',
@@ -231,5 +235,5 @@ export const ovmRequestWithdrawalPayloadSchema = {
231
235
  },
232
236
  },
233
237
  validateOVMRequestWithdrawalPayload: true,
234
- required: ['ovmAddress', 'pubKeys', 'amounts'],
238
+ required: ['ovmAddress', 'pubKeys', 'amounts', 'withdrawalFees'],
235
239
  };
@@ -492,13 +492,15 @@ const getChainConfig = (chainId) => {
492
492
  * @param signer - The signer to use for the transaction
493
493
  * @returns Promise that resolves to the transaction hash
494
494
  */
495
- export const requestWithdrawalFromOVM = ({ ovmAddress, pubKeys, amounts, signer, }) => __awaiter(void 0, void 0, void 0, function* () {
495
+ export const requestWithdrawalFromOVM = ({ ovmAddress, pubKeys, amounts, withdrawalFees, signer, }) => __awaiter(void 0, void 0, void 0, function* () {
496
496
  var _15;
497
497
  try {
498
498
  // Convert string amounts to bigint
499
499
  const bigintAmounts = amounts.map(amount => BigInt(amount));
500
500
  const ovmContract = new Contract(ovmAddress, OVMContract.abi, signer);
501
- const tx = yield ovmContract.requestWithdrawal(pubKeys, bigintAmounts);
501
+ const tx = yield ovmContract.requestWithdrawal(pubKeys, bigintAmounts, {
502
+ value: BigInt(withdrawalFees),
503
+ });
502
504
  const receipt = yield tx.wait();
503
505
  return { txHash: receipt.hash };
504
506
  }
@@ -311,6 +311,7 @@ export class ObolSplits {
311
311
  ovmAddress: validatedPayload.ovmAddress,
312
312
  pubKeys: validatedPayload.pubKeys,
313
313
  amounts: validatedPayload.amounts,
314
+ withdrawalFees: validatedPayload.withdrawalFees,
314
315
  signer: this.signer,
315
316
  });
316
317
  });
@@ -272,6 +272,7 @@ describe('ovmRequestWithdrawalPayloadSchema', () => {
272
272
  '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
273
273
  ],
274
274
  amounts: ['32000000000'],
275
+ withdrawalFees: '1',
275
276
  };
276
277
  it('should throw error when OVM address is missing', () => {
277
278
  const payload = {
@@ -286,14 +287,32 @@ describe('ovmRequestWithdrawalPayloadSchema', () => {
286
287
  pubKeys: validPayload.pubKeys,
287
288
  amounts: validPayload.amounts,
288
289
  };
289
- expect(() => validatePayload(payload, ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: /ovmAddress must match pattern');
290
+ expect(() => validatePayload(payload, ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: must have required property \'withdrawalFees\', /ovmAddress must match pattern "^0x[a-fA-F0-9]{40}$"');
290
291
  });
291
292
  it('should throw error when number of public keys does not match number of amounts', () => {
292
293
  const payload = {
293
294
  ovmAddress: validPayload.ovmAddress,
294
295
  pubKeys: validPayload.pubKeys,
295
296
  amounts: ['32000000000', '16000000000'], // 2 amounts, 1 pubKey
297
+ withdrawalFees: validPayload.withdrawalFees,
296
298
  };
297
299
  expect(() => validatePayload(payload, ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: must pass "validateOVMRequestWithdrawalPayload" keyword validation');
298
300
  });
301
+ it('should throw error when withdrawalFees is missing', () => {
302
+ const payload = {
303
+ ovmAddress: validPayload.ovmAddress,
304
+ pubKeys: validPayload.pubKeys,
305
+ amounts: validPayload.amounts,
306
+ };
307
+ expect(() => validatePayload(payload, ovmRequestWithdrawalPayloadSchema)).toThrow("Validation failed: must have required property 'withdrawalFees'");
308
+ });
309
+ it('should throw error when withdrawalFees is invalid', () => {
310
+ const payload = {
311
+ ovmAddress: validPayload.ovmAddress,
312
+ pubKeys: validPayload.pubKeys,
313
+ amounts: validPayload.amounts,
314
+ withdrawalFees: 'invalid',
315
+ };
316
+ expect(() => validatePayload(payload, ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: /withdrawalFees must match pattern "^[0-9]+$"');
317
+ });
299
318
  });
@@ -244,6 +244,7 @@ describe('ObolSplits', () => {
244
244
  ovmAddress: mockOVMAddress,
245
245
  pubKeys: mockPubKeys,
246
246
  amounts: mockAmounts,
247
+ withdrawalFees: '1',
247
248
  });
248
249
  expect(result).toEqual({
249
250
  txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
@@ -252,6 +253,7 @@ describe('ObolSplits', () => {
252
253
  ovmAddress: mockOVMAddress,
253
254
  pubKeys: mockPubKeys,
254
255
  amounts: mockAmounts,
256
+ withdrawalFees: '1',
255
257
  signer: mockSigner,
256
258
  });
257
259
  }));
@@ -261,6 +263,7 @@ describe('ObolSplits', () => {
261
263
  ovmAddress: mockOVMAddress,
262
264
  pubKeys: mockPubKeys,
263
265
  amounts: mockAmounts,
266
+ withdrawalFees: '1',
264
267
  })).rejects.toThrow('Signer is required in requestWithdrawal');
265
268
  }));
266
269
  // it('should throw error when amount is below minimum (1,000,000 gwei)', async () => {
@@ -288,6 +291,7 @@ describe('ObolSplits', () => {
288
291
  ovmAddress: mockOVMAddress,
289
292
  pubKeys: multiplePubKeys,
290
293
  amounts: multipleAmounts,
294
+ withdrawalFees: '1',
291
295
  });
292
296
  expect(result).toEqual({
293
297
  txHash: '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
@@ -296,6 +300,7 @@ describe('ObolSplits', () => {
296
300
  ovmAddress: mockOVMAddress,
297
301
  pubKeys: multiplePubKeys,
298
302
  amounts: multipleAmounts,
303
+ withdrawalFees: '1',
299
304
  signer: mockSigner,
300
305
  });
301
306
  }));
@@ -324,6 +324,10 @@ export declare const ovmTotalSplitPayloadSchema: {
324
324
  export declare const ovmRequestWithdrawalPayloadSchema: {
325
325
  type: string;
326
326
  properties: {
327
+ withdrawalFees: {
328
+ type: string;
329
+ pattern: string;
330
+ };
327
331
  ovmAddress: {
328
332
  type: string;
329
333
  pattern: string;
@@ -107,10 +107,11 @@ export declare const deployOVMAndSplitV2: ({ ovmArgs, rewardRecipients, isReward
107
107
  * @param signer - The signer to use for the transaction
108
108
  * @returns Promise that resolves to the transaction hash
109
109
  */
110
- export declare const requestWithdrawalFromOVM: ({ ovmAddress, pubKeys, amounts, signer, }: {
110
+ export declare const requestWithdrawalFromOVM: ({ ovmAddress, pubKeys, amounts, withdrawalFees, signer, }: {
111
111
  ovmAddress: string;
112
112
  pubKeys: string[];
113
113
  amounts: string[];
114
+ withdrawalFees: string;
114
115
  signer: SignerType;
115
116
  }) => Promise<{
116
117
  txHash: string;
@@ -476,6 +476,8 @@ export type ChainConfig = {
476
476
  * Payload for requesting withdrawal from OVM contract
477
477
  */
478
478
  export type OVMRequestWithdrawalPayload = {
479
+ /** request withdrawal fees in wei */
480
+ withdrawalFees: string;
479
481
  /** OVM contract address */
480
482
  ovmAddress: string;
481
483
  /** Array of validator public keys in bytes format */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
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"
package/src/ajv.ts CHANGED
@@ -112,7 +112,6 @@ const validateOVMRequestWithdrawalPayload = (
112
112
  _: boolean,
113
113
  data: OVMRequestWithdrawalPayload,
114
114
  ): boolean => {
115
- console.log(data, 'hanaaan dataaaa');
116
115
  if (!data.pubKeys || !data.amounts) {
117
116
  return false;
118
117
  }
package/src/schema.ts CHANGED
@@ -233,6 +233,10 @@ export const ovmTotalSplitPayloadSchema = {
233
233
  export const ovmRequestWithdrawalPayloadSchema = {
234
234
  type: 'object',
235
235
  properties: {
236
+ withdrawalFees: {
237
+ type: 'string',
238
+ pattern: '^[0-9]+$',
239
+ },
236
240
  ovmAddress: {
237
241
  type: 'string',
238
242
  pattern: '^0x[a-fA-F0-9]{40}$',
@@ -255,5 +259,5 @@ export const ovmRequestWithdrawalPayloadSchema = {
255
259
  },
256
260
  },
257
261
  validateOVMRequestWithdrawalPayload: true,
258
- required: ['ovmAddress', 'pubKeys', 'amounts'],
262
+ required: ['ovmAddress', 'pubKeys', 'amounts', 'withdrawalFees'],
259
263
  };
@@ -923,11 +923,13 @@ export const requestWithdrawalFromOVM = async ({
923
923
  ovmAddress,
924
924
  pubKeys,
925
925
  amounts,
926
+ withdrawalFees,
926
927
  signer,
927
928
  }: {
928
929
  ovmAddress: string;
929
930
  pubKeys: string[];
930
931
  amounts: string[];
932
+ withdrawalFees: string;
931
933
  signer: SignerType;
932
934
  }): Promise<{ txHash: string }> => {
933
935
  try {
@@ -936,7 +938,9 @@ export const requestWithdrawalFromOVM = async ({
936
938
 
937
939
  const ovmContract = new Contract(ovmAddress, OVMContract.abi, signer);
938
940
 
939
- const tx = await ovmContract.requestWithdrawal(pubKeys, bigintAmounts);
941
+ const tx = await ovmContract.requestWithdrawal(pubKeys, bigintAmounts, {
942
+ value: BigInt(withdrawalFees),
943
+ });
940
944
  const receipt = await tx.wait();
941
945
 
942
946
  return { txHash: receipt.hash };
@@ -447,6 +447,7 @@ export class ObolSplits {
447
447
  ovmAddress: validatedPayload.ovmAddress,
448
448
  pubKeys: validatedPayload.pubKeys,
449
449
  amounts: validatedPayload.amounts,
450
+ withdrawalFees: validatedPayload.withdrawalFees,
450
451
  signer: this.signer,
451
452
  });
452
453
  }
package/src/types.ts CHANGED
@@ -612,6 +612,9 @@ export type ChainConfig = {
612
612
  * Payload for requesting withdrawal from OVM contract
613
613
  */
614
614
  export type OVMRequestWithdrawalPayload = {
615
+ /** request withdrawal fees in wei */
616
+ withdrawalFees: string;
617
+
615
618
  /** OVM contract address */
616
619
  ovmAddress: string;
617
620