@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.
@@ -208,18 +208,13 @@ const computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = from
208
208
  * @param {string} withdrawalAddress - withdrawal address in definition file.
209
209
  * @returns {boolean} - return if deposit data is valid.
210
210
  */
211
- export const verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion) => {
211
+ export const verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding) => {
212
212
  const depositDomain = computeDomain(fromHexString(DOMAIN_DEPOSIT), forkVersion);
213
- const eth1AddressWithdrawalPrefix = '0x01';
214
- const compoundingWithdrawalPrefix = '0x02';
215
- if (eth1AddressWithdrawalPrefix +
213
+ const withdrawalPrefix = compounding ? '0x02' : '0x01';
214
+ const expectedWithdrawalCredentials = withdrawalPrefix +
216
215
  '0'.repeat(22) +
217
- withdrawalAddress.toLowerCase().slice(2) !==
218
- depositData.withdrawal_credentials &&
219
- compoundingWithdrawalPrefix +
220
- '0'.repeat(22) +
221
- withdrawalAddress.toLowerCase().slice(2) !==
222
- depositData.withdrawal_credentials) {
216
+ withdrawalAddress.toLowerCase().slice(2);
217
+ if (expectedWithdrawalCredentials !== depositData.withdrawal_credentials) {
223
218
  return { isValidDepositData: false, depositDataMsg: new Uint8Array(0) };
224
219
  }
225
220
  if (distributedPublicKey !== depositData.pubkey) {
@@ -1,7 +1,7 @@
1
1
  import { UintNumberType, } from '@chainsafe/ssz/lib/type/uint';
2
2
  import { strToUint8Array } from '../utils';
3
3
  import { builderRegistrationContainer, depositDataContainer, newCreatorContainerType, newOperatorContainerType, validatorsContainerType, } from './sszTypes';
4
- import { ByteListType, ByteVectorType, ContainerType, ListBasicType, ListCompositeType, fromHexString, } from '@chainsafe/ssz';
4
+ import { ByteListType, ByteVectorType, ContainerType, ListBasicType, ListCompositeType, fromHexString, BooleanType, } from '@chainsafe/ssz';
5
5
  import { verifyDVV1X8 } from './v1.8.0';
6
6
  /**
7
7
  * Returns the containerized cluster definition
@@ -24,6 +24,7 @@ export const clusterDefinitionContainerTypeV1X10 = (configOnly) => {
24
24
  deposit_amounts: new ListBasicType(new UintNumberType(8), 256),
25
25
  consensus_protocol: new ByteListType(256),
26
26
  target_gas_limit: new UintNumberType(8),
27
+ compounding: new BooleanType(),
27
28
  };
28
29
  if (!configOnly) {
29
30
  returnedContainerType = Object.assign(Object.assign({}, returnedContainerType), { config_hash: new ByteVectorType(32) });
@@ -75,6 +76,9 @@ export const hashClusterDefinitionV1X10 = (cluster, configOnly) => {
75
76
  if (cluster.target_gas_limit) {
76
77
  val.target_gas_limit = cluster.target_gas_limit;
77
78
  }
79
+ if (cluster.compounding) {
80
+ val.compounding = cluster.compounding;
81
+ }
78
82
  if (!configOnly) {
79
83
  val.config_hash = fromHexString(cluster.config_hash);
80
84
  }
@@ -144,7 +144,7 @@ export const verifyDVV1X8 = (clusterLock) => {
144
144
  // Deposit Data Verification
145
145
  for (const element of validator.partial_deposit_data) {
146
146
  const depositData = element;
147
- const { isValidDepositData, depositDataMsg } = verifyDepositData(distributedPublicKey, depositData, clusterLock.cluster_definition.validators[i].withdrawal_address, clusterLock.cluster_definition.fork_version);
147
+ const { isValidDepositData, depositDataMsg } = verifyDepositData(distributedPublicKey, depositData, clusterLock.cluster_definition.validators[i].withdrawal_address, clusterLock.cluster_definition.fork_version, clusterLock.cluster_definition.compounding);
148
148
  if (!isValidDepositData) {
149
149
  return false;
150
150
  }