@obolnetwork/obol-sdk 2.2.3 → 2.2.4

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
  import { UintNumberType } from '@chainsafe/ssz/lib/type/uint';
2
2
  import { type creatorAddressWrapperType, type creatorContainerType, type operatorAddressWrapperType, type operatorContainerType, validatorsContainerType } from './sszTypes';
3
- import { ByteListType, ByteVectorType, ContainerType, ListBasicType, ListCompositeType } from '@chainsafe/ssz';
3
+ import { ByteListType, ByteVectorType, ContainerType, ListBasicType, ListCompositeType, BooleanType } from '@chainsafe/ssz';
4
4
  import { type ValueOfFields } from '@chainsafe/ssz/lib/view/container';
5
5
  import { type ClusterDefinition, type ClusterLock } from '../types';
6
6
  type DefinitionFieldsV1X10 = {
@@ -18,6 +18,7 @@ type DefinitionFieldsV1X10 = {
18
18
  deposit_amounts: ListBasicType<UintNumberType>;
19
19
  consensus_protocol: ByteListType;
20
20
  target_gas_limit: UintNumberType;
21
+ compounding: BooleanType;
21
22
  config_hash?: ByteVectorType;
22
23
  };
23
24
  type DefinitionContainerTypeV1X10 = ContainerType<DefinitionFieldsV1X10>;
@@ -290,6 +290,61 @@ export declare const clusterLockV1X10: {
290
290
  deposit_amounts: null;
291
291
  consensus_protocol: string;
292
292
  target_gas_limit: number;
293
+ compounding: boolean;
294
+ config_hash: string;
295
+ definition_hash: string;
296
+ };
297
+ distributed_validators: {
298
+ distributed_public_key: string;
299
+ public_shares: string[];
300
+ builder_registration: {
301
+ message: {
302
+ fee_recipient: string;
303
+ gas_limit: number;
304
+ timestamp: number;
305
+ pubkey: string;
306
+ };
307
+ signature: string;
308
+ };
309
+ partial_deposit_data: {
310
+ pubkey: string;
311
+ withdrawal_credentials: string;
312
+ amount: string;
313
+ signature: string;
314
+ }[];
315
+ }[];
316
+ signature_aggregate: string;
317
+ lock_hash: string;
318
+ node_signatures: string[];
319
+ };
320
+ export declare const clusterLockWithCompoundingWithdrawals: {
321
+ cluster_definition: {
322
+ name: string;
323
+ creator: {
324
+ address: string;
325
+ config_signature: string;
326
+ };
327
+ operators: {
328
+ address: string;
329
+ enr: string;
330
+ config_signature: string;
331
+ enr_signature: string;
332
+ }[];
333
+ uuid: string;
334
+ version: string;
335
+ timestamp: string;
336
+ num_validators: number;
337
+ threshold: number;
338
+ validators: {
339
+ fee_recipient_address: string;
340
+ withdrawal_address: string;
341
+ }[];
342
+ dkg_algorithm: string;
343
+ fork_version: string;
344
+ deposit_amounts: null;
345
+ consensus_protocol: string;
346
+ target_gas_limit: number;
347
+ compounding: boolean;
293
348
  config_hash: string;
294
349
  definition_hash: string;
295
350
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
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/types.ts CHANGED
@@ -144,6 +144,9 @@ export interface ClusterDefinition extends ClusterPayload {
144
144
 
145
145
  /** The target gas limit where default is 30M. */
146
146
  target_gas_limit?: number;
147
+
148
+ /** A withdrawal mechanism with 0x02 withdrawal credentials. */
149
+ compounding?: boolean;
147
150
  }
148
151
 
149
152
  /**
@@ -354,23 +354,19 @@ export const verifyDepositData = (
354
354
  depositData: Partial<DepositData>,
355
355
  withdrawalAddress: string,
356
356
  forkVersion: string,
357
+ compounding?: boolean,
357
358
  ): { isValidDepositData: boolean; depositDataMsg: Uint8Array } => {
358
359
  const depositDomain = computeDomain(
359
360
  fromHexString(DOMAIN_DEPOSIT),
360
361
  forkVersion,
361
362
  );
362
- const eth1AddressWithdrawalPrefix = '0x01';
363
- const compoundingWithdrawalPrefix = '0x02';
364
- if (
365
- eth1AddressWithdrawalPrefix +
366
- '0'.repeat(22) +
367
- withdrawalAddress.toLowerCase().slice(2) !==
368
- depositData.withdrawal_credentials &&
369
- compoundingWithdrawalPrefix +
370
- '0'.repeat(22) +
371
- withdrawalAddress.toLowerCase().slice(2) !==
372
- depositData.withdrawal_credentials
373
- ) {
363
+ const withdrawalPrefix = compounding ? '0x02' : '0x01';
364
+ const expectedWithdrawalCredentials =
365
+ withdrawalPrefix +
366
+ '0'.repeat(22) +
367
+ withdrawalAddress.toLowerCase().slice(2);
368
+
369
+ if (expectedWithdrawalCredentials !== depositData.withdrawal_credentials) {
374
370
  return { isValidDepositData: false, depositDataMsg: new Uint8Array(0) };
375
371
  }
376
372
 
@@ -21,6 +21,7 @@ import {
21
21
  ListBasicType,
22
22
  ListCompositeType,
23
23
  fromHexString,
24
+ BooleanType,
24
25
  } from '@chainsafe/ssz';
25
26
  import { type ValueOfFields } from '@chainsafe/ssz/lib/view/container';
26
27
  import {
@@ -48,6 +49,7 @@ type DefinitionFieldsV1X10 = {
48
49
  deposit_amounts: ListBasicType<UintNumberType>;
49
50
  consensus_protocol: ByteListType;
50
51
  target_gas_limit: UintNumberType;
52
+ compounding: BooleanType;
51
53
  config_hash?: ByteVectorType;
52
54
  };
53
55
 
@@ -79,6 +81,7 @@ export const clusterDefinitionContainerTypeV1X10 = (
79
81
  ),
80
82
  consensus_protocol: new ByteListType(256),
81
83
  target_gas_limit: new UintNumberType(8 as UintNumberByteLen),
84
+ compounding: new BooleanType(),
82
85
  };
83
86
 
84
87
  if (!configOnly) {
@@ -144,6 +147,10 @@ export const hashClusterDefinitionV1X10 = (
144
147
  val.target_gas_limit = cluster.target_gas_limit;
145
148
  }
146
149
 
150
+ if (cluster.compounding) {
151
+ val.compounding = cluster.compounding;
152
+ }
153
+
147
154
  if (!configOnly) {
148
155
  val.config_hash = fromHexString(cluster.config_hash);
149
156
  }
@@ -259,6 +259,7 @@ export const verifyDVV1X8 = (clusterLock: ClusterLock): boolean => {
259
259
  depositData as Partial<DepositData>,
260
260
  clusterLock.cluster_definition.validators[i].withdrawal_address,
261
261
  clusterLock.cluster_definition.fork_version,
262
+ clusterLock.cluster_definition.compounding,
262
263
  );
263
264
 
264
265
  if (!isValidDepositData) {