@obolnetwork/obol-sdk 2.11.2 → 2.11.3

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.11.2",
3
+ "version": "2.11.3",
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"
@@ -149,19 +149,12 @@ const verifyDVV1X8 = (clusterLock) => {
149
149
  }
150
150
  // Check deposit amounts match exactly if they are defined
151
151
  const depositAmounts = clusterLock.cluster_definition.deposit_amounts;
152
- if (depositAmounts !== null) {
152
+ if (!!depositAmounts && depositAmounts !== null) {
153
153
  const partialDepositAmounts = validator.partial_deposit_data.map(d => d.amount);
154
- if ((depositAmounts === null || depositAmounts === void 0 ? void 0 : depositAmounts.length) !== partialDepositAmounts.length) {
155
- return false;
156
- }
157
- // Check that both arrays contain exactly the same elements
158
- const sortedDepositAmounts = [...depositAmounts]
159
- .map(Number)
160
- .sort((a, b) => a - b);
161
- const sortedPartialAmounts = [...partialDepositAmounts]
162
- .map(Number)
163
- .sort((a, b) => a - b);
164
- if (!sortedDepositAmounts.every((amount, index) => amount === sortedPartialAmounts[index])) {
154
+ // Check that partialDepositAmounts includes all unique elements of depositAmounts
155
+ const uniqueDepositAmounts = [...new Set(depositAmounts.map(Number))];
156
+ const partialAmountsSet = new Set(partialDepositAmounts.map(Number));
157
+ if (!uniqueDepositAmounts.every(amount => partialAmountsSet.has(amount))) {
165
158
  return false;
166
159
  }
167
160
  }
@@ -101,7 +101,7 @@ describe('EOA', () => {
101
101
  {
102
102
  pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
103
103
  withdrawal_credentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
104
- deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
104
+ deposit_data_root: '0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01',
105
105
  signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
106
106
  amount: '32000000000000000000', // 32 ETH in wei
107
107
  },
@@ -143,14 +143,14 @@ describe('EOA', () => {
143
143
  {
144
144
  pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
145
145
  withdrawal_credentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
146
- deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
146
+ deposit_data_root: '0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01',
147
147
  signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
148
148
  amount: '32000000000000000000',
149
149
  },
150
150
  {
151
151
  pubkey: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdcd',
152
152
  withdrawal_credentials: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
153
- deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
153
+ deposit_data_root: '0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01',
154
154
  signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
155
155
  amount: '16000000000000000000',
156
156
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.11.2",
3
+ "version": "2.11.3",
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"
@@ -143,19 +143,12 @@ export const verifyDVV1X8 = (clusterLock) => {
143
143
  }
144
144
  // Check deposit amounts match exactly if they are defined
145
145
  const depositAmounts = clusterLock.cluster_definition.deposit_amounts;
146
- if (depositAmounts !== null) {
146
+ if (!!depositAmounts && depositAmounts !== null) {
147
147
  const partialDepositAmounts = validator.partial_deposit_data.map(d => d.amount);
148
- if ((depositAmounts === null || depositAmounts === void 0 ? void 0 : depositAmounts.length) !== partialDepositAmounts.length) {
149
- return false;
150
- }
151
- // Check that both arrays contain exactly the same elements
152
- const sortedDepositAmounts = [...depositAmounts]
153
- .map(Number)
154
- .sort((a, b) => a - b);
155
- const sortedPartialAmounts = [...partialDepositAmounts]
156
- .map(Number)
157
- .sort((a, b) => a - b);
158
- if (!sortedDepositAmounts.every((amount, index) => amount === sortedPartialAmounts[index])) {
148
+ // Check that partialDepositAmounts includes all unique elements of depositAmounts
149
+ const uniqueDepositAmounts = [...new Set(depositAmounts.map(Number))];
150
+ const partialAmountsSet = new Set(partialDepositAmounts.map(Number));
151
+ if (!uniqueDepositAmounts.every(amount => partialAmountsSet.has(amount))) {
159
152
  return false;
160
153
  }
161
154
  }
@@ -99,7 +99,7 @@ describe('EOA', () => {
99
99
  {
100
100
  pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
101
101
  withdrawal_credentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
102
- deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
102
+ deposit_data_root: '0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01',
103
103
  signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
104
104
  amount: '32000000000000000000', // 32 ETH in wei
105
105
  },
@@ -141,14 +141,14 @@ describe('EOA', () => {
141
141
  {
142
142
  pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
143
143
  withdrawal_credentials: '0x1234567890123456789012345678901234567890123456789012345678901234',
144
- deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
144
+ deposit_data_root: '0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01',
145
145
  signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
146
146
  amount: '32000000000000000000',
147
147
  },
148
148
  {
149
149
  pubkey: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdcd',
150
150
  withdrawal_credentials: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd',
151
- deposit_data_root: "0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01",
151
+ deposit_data_root: '0x7f7f280756b8d5fe06ae922e5a20afb708c0f00d8954caede4c262795d956c01',
152
152
  signature: '0x121234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012000000000000000000',
153
153
  amount: '16000000000000000000',
154
154
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.11.2",
3
+ "version": "2.11.3",
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"
@@ -253,24 +253,17 @@ export const verifyDVV1X8 = (clusterLock: ClusterLock): boolean => {
253
253
 
254
254
  // Check deposit amounts match exactly if they are defined
255
255
  const depositAmounts = clusterLock.cluster_definition.deposit_amounts;
256
- if (depositAmounts !== null) {
256
+ if (!!depositAmounts && depositAmounts !== null) {
257
257
  const partialDepositAmounts = (
258
258
  validator.partial_deposit_data as DepositData[]
259
259
  ).map(d => d.amount);
260
- if (depositAmounts?.length !== partialDepositAmounts.length) {
261
- return false;
262
- }
263
- // Check that both arrays contain exactly the same elements
264
- const sortedDepositAmounts = [...depositAmounts]
265
- .map(Number)
266
- .sort((a, b) => a - b);
267
- const sortedPartialAmounts = [...partialDepositAmounts]
268
- .map(Number)
269
- .sort((a, b) => a - b);
260
+
261
+ // Check that partialDepositAmounts includes all unique elements of depositAmounts
262
+ const uniqueDepositAmounts = [...new Set(depositAmounts.map(Number))];
263
+ const partialAmountsSet = new Set(partialDepositAmounts.map(Number));
264
+
270
265
  if (
271
- !sortedDepositAmounts.every(
272
- (amount, index) => amount === sortedPartialAmounts[index],
273
- )
266
+ !uniqueDepositAmounts.every(amount => partialAmountsSet.has(amount))
274
267
  ) {
275
268
  return false;
276
269
  }