@obolnetwork/obol-sdk 2.8.0 → 2.9.0

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.
Files changed (40) hide show
  1. package/dist/cjs/package.json +2 -4
  2. package/dist/cjs/src/abi/splitV2FactoryAbi.js +420 -0
  3. package/dist/cjs/src/ajv.js +24 -0
  4. package/dist/cjs/src/bytecodes.js +3 -1
  5. package/dist/cjs/src/constants.js +24 -16
  6. package/dist/cjs/src/index.js +10 -10
  7. package/dist/cjs/src/schema.js +29 -3
  8. package/dist/cjs/src/splits/splitHelpers.js +100 -109
  9. package/dist/cjs/src/splits/splits.js +77 -16
  10. package/dist/cjs/test/client/ajv.spec.js +32 -0
  11. package/dist/cjs/test/splits/splits.spec.js +76 -2
  12. package/dist/esm/package.json +2 -4
  13. package/dist/esm/src/abi/splitV2FactoryAbi.js +417 -0
  14. package/dist/esm/src/ajv.js +24 -0
  15. package/dist/esm/src/bytecodes.js +2 -0
  16. package/dist/esm/src/constants.js +25 -17
  17. package/dist/esm/src/index.js +10 -10
  18. package/dist/esm/src/schema.js +28 -2
  19. package/dist/esm/src/splits/splitHelpers.js +101 -110
  20. package/dist/esm/src/splits/splits.js +79 -18
  21. package/dist/esm/test/client/ajv.spec.js +33 -1
  22. package/dist/esm/test/splits/splits.spec.js +77 -3
  23. package/dist/types/src/abi/splitV2FactoryAbi.d.ts +60 -0
  24. package/dist/types/src/bytecodes.d.ts +2 -0
  25. package/dist/types/src/exits/verificationHelpers.d.ts +1 -0
  26. package/dist/types/src/schema.d.ts +30 -3
  27. package/dist/types/src/splits/splitHelpers.d.ts +17 -3
  28. package/dist/types/src/splits/splits.d.ts +28 -1
  29. package/dist/types/src/types.d.ts +21 -6
  30. package/dist/types/src/verification/common.d.ts +1 -0
  31. package/package.json +2 -4
  32. package/src/abi/splitV2FactoryAbi.ts +417 -0
  33. package/src/ajv.ts +33 -0
  34. package/src/bytecodes.ts +4 -0
  35. package/src/constants.ts +26 -16
  36. package/src/index.ts +14 -14
  37. package/src/schema.ts +29 -2
  38. package/src/splits/splitHelpers.ts +169 -124
  39. package/src/splits/splits.ts +115 -17
  40. package/src/types.ts +24 -6
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
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"
@@ -40,7 +40,6 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@0xsplits/splits-sdk": "^5.1.0",
44
43
  "@chainsafe/bls": "6.0.3",
45
44
  "@chainsafe/blst": "^0.2.9",
46
45
  "@chainsafe/discv5": "^0.5.1",
@@ -64,8 +63,7 @@
64
63
  "pdf-parse": "^1.1.1",
65
64
  "semver": "^7.6.0",
66
65
  "typescript-eslint": "^7.1.0",
67
- "uuid": "^9.0.0",
68
- "viem": "^2.31.4"
66
+ "uuid": "^9.0.0"
69
67
  },
70
68
  "devDependencies": {
71
69
  "@release-it/conventional-changelog": "^8.0.1",
@@ -0,0 +1,420 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitV2FactoryAbi = void 0;
4
+ exports.splitV2FactoryAbi = [
5
+ {
6
+ inputs: [
7
+ {
8
+ internalType: 'address',
9
+ name: '_splitsWarehouse',
10
+ type: 'address',
11
+ },
12
+ ],
13
+ stateMutability: 'nonpayable',
14
+ type: 'constructor',
15
+ },
16
+ {
17
+ anonymous: false,
18
+ inputs: [
19
+ {
20
+ indexed: true,
21
+ internalType: 'address',
22
+ name: 'split',
23
+ type: 'address',
24
+ },
25
+ {
26
+ components: [
27
+ {
28
+ internalType: 'address[]',
29
+ name: 'recipients',
30
+ type: 'address[]',
31
+ },
32
+ {
33
+ internalType: 'uint256[]',
34
+ name: 'allocations',
35
+ type: 'uint256[]',
36
+ },
37
+ {
38
+ internalType: 'uint256',
39
+ name: 'totalAllocation',
40
+ type: 'uint256',
41
+ },
42
+ {
43
+ internalType: 'uint16',
44
+ name: 'distributionIncentive',
45
+ type: 'uint16',
46
+ },
47
+ ],
48
+ indexed: false,
49
+ internalType: 'struct SplitV2Lib.Split',
50
+ name: 'splitParams',
51
+ type: 'tuple',
52
+ },
53
+ {
54
+ indexed: false,
55
+ internalType: 'address',
56
+ name: 'owner',
57
+ type: 'address',
58
+ },
59
+ {
60
+ indexed: false,
61
+ internalType: 'address',
62
+ name: 'creator',
63
+ type: 'address',
64
+ },
65
+ {
66
+ indexed: false,
67
+ internalType: 'bytes32',
68
+ name: 'salt',
69
+ type: 'bytes32',
70
+ },
71
+ ],
72
+ name: 'SplitCreated',
73
+ type: 'event',
74
+ },
75
+ {
76
+ anonymous: false,
77
+ inputs: [
78
+ {
79
+ indexed: true,
80
+ internalType: 'address',
81
+ name: 'split',
82
+ type: 'address',
83
+ },
84
+ {
85
+ components: [
86
+ {
87
+ internalType: 'address[]',
88
+ name: 'recipients',
89
+ type: 'address[]',
90
+ },
91
+ {
92
+ internalType: 'uint256[]',
93
+ name: 'allocations',
94
+ type: 'uint256[]',
95
+ },
96
+ {
97
+ internalType: 'uint256',
98
+ name: 'totalAllocation',
99
+ type: 'uint256',
100
+ },
101
+ {
102
+ internalType: 'uint16',
103
+ name: 'distributionIncentive',
104
+ type: 'uint16',
105
+ },
106
+ ],
107
+ indexed: false,
108
+ internalType: 'struct SplitV2Lib.Split',
109
+ name: 'splitParams',
110
+ type: 'tuple',
111
+ },
112
+ {
113
+ indexed: false,
114
+ internalType: 'address',
115
+ name: 'owner',
116
+ type: 'address',
117
+ },
118
+ {
119
+ indexed: false,
120
+ internalType: 'address',
121
+ name: 'creator',
122
+ type: 'address',
123
+ },
124
+ ],
125
+ name: 'SplitCreated',
126
+ type: 'event',
127
+ },
128
+ {
129
+ inputs: [],
130
+ name: 'SPLIT_WALLET_IMPLEMENTATION',
131
+ outputs: [
132
+ {
133
+ internalType: 'address',
134
+ name: '',
135
+ type: 'address',
136
+ },
137
+ ],
138
+ stateMutability: 'view',
139
+ type: 'function',
140
+ },
141
+ {
142
+ inputs: [
143
+ {
144
+ components: [
145
+ {
146
+ internalType: 'address[]',
147
+ name: 'recipients',
148
+ type: 'address[]',
149
+ },
150
+ {
151
+ internalType: 'uint256[]',
152
+ name: 'allocations',
153
+ type: 'uint256[]',
154
+ },
155
+ {
156
+ internalType: 'uint256',
157
+ name: 'totalAllocation',
158
+ type: 'uint256',
159
+ },
160
+ {
161
+ internalType: 'uint16',
162
+ name: 'distributionIncentive',
163
+ type: 'uint16',
164
+ },
165
+ ],
166
+ internalType: 'struct SplitV2Lib.Split',
167
+ name: '_splitParams',
168
+ type: 'tuple',
169
+ },
170
+ {
171
+ internalType: 'address',
172
+ name: '_owner',
173
+ type: 'address',
174
+ },
175
+ {
176
+ internalType: 'address',
177
+ name: '_creator',
178
+ type: 'address',
179
+ },
180
+ ],
181
+ name: 'createSplit',
182
+ outputs: [
183
+ {
184
+ internalType: 'address',
185
+ name: 'split',
186
+ type: 'address',
187
+ },
188
+ ],
189
+ stateMutability: 'nonpayable',
190
+ type: 'function',
191
+ },
192
+ {
193
+ inputs: [
194
+ {
195
+ components: [
196
+ {
197
+ internalType: 'address[]',
198
+ name: 'recipients',
199
+ type: 'address[]',
200
+ },
201
+ {
202
+ internalType: 'uint256[]',
203
+ name: 'allocations',
204
+ type: 'uint256[]',
205
+ },
206
+ {
207
+ internalType: 'uint256',
208
+ name: 'totalAllocation',
209
+ type: 'uint256',
210
+ },
211
+ {
212
+ internalType: 'uint16',
213
+ name: 'distributionIncentive',
214
+ type: 'uint16',
215
+ },
216
+ ],
217
+ internalType: 'struct SplitV2Lib.Split',
218
+ name: '_splitParams',
219
+ type: 'tuple',
220
+ },
221
+ {
222
+ internalType: 'address',
223
+ name: '_owner',
224
+ type: 'address',
225
+ },
226
+ {
227
+ internalType: 'address',
228
+ name: '_creator',
229
+ type: 'address',
230
+ },
231
+ {
232
+ internalType: 'bytes32',
233
+ name: '_salt',
234
+ type: 'bytes32',
235
+ },
236
+ ],
237
+ name: 'createSplitDeterministic',
238
+ outputs: [
239
+ {
240
+ internalType: 'address',
241
+ name: 'split',
242
+ type: 'address',
243
+ },
244
+ ],
245
+ stateMutability: 'nonpayable',
246
+ type: 'function',
247
+ },
248
+ {
249
+ inputs: [
250
+ {
251
+ components: [
252
+ {
253
+ internalType: 'address[]',
254
+ name: 'recipients',
255
+ type: 'address[]',
256
+ },
257
+ {
258
+ internalType: 'uint256[]',
259
+ name: 'allocations',
260
+ type: 'uint256[]',
261
+ },
262
+ {
263
+ internalType: 'uint256',
264
+ name: 'totalAllocation',
265
+ type: 'uint256',
266
+ },
267
+ {
268
+ internalType: 'uint16',
269
+ name: 'distributionIncentive',
270
+ type: 'uint16',
271
+ },
272
+ ],
273
+ internalType: 'struct SplitV2Lib.Split',
274
+ name: '_splitParams',
275
+ type: 'tuple',
276
+ },
277
+ {
278
+ internalType: 'address',
279
+ name: '_owner',
280
+ type: 'address',
281
+ },
282
+ {
283
+ internalType: 'bytes32',
284
+ name: '_salt',
285
+ type: 'bytes32',
286
+ },
287
+ ],
288
+ name: 'isDeployed',
289
+ outputs: [
290
+ {
291
+ internalType: 'address',
292
+ name: 'split',
293
+ type: 'address',
294
+ },
295
+ {
296
+ internalType: 'bool',
297
+ name: 'exists',
298
+ type: 'bool',
299
+ },
300
+ ],
301
+ stateMutability: 'view',
302
+ type: 'function',
303
+ },
304
+ {
305
+ inputs: [
306
+ {
307
+ internalType: 'bytes32',
308
+ name: '_hash',
309
+ type: 'bytes32',
310
+ },
311
+ ],
312
+ name: 'nonces',
313
+ outputs: [
314
+ {
315
+ internalType: 'uint256',
316
+ name: '',
317
+ type: 'uint256',
318
+ },
319
+ ],
320
+ stateMutability: 'view',
321
+ type: 'function',
322
+ },
323
+ {
324
+ inputs: [
325
+ {
326
+ components: [
327
+ {
328
+ internalType: 'address[]',
329
+ name: 'recipients',
330
+ type: 'address[]',
331
+ },
332
+ {
333
+ internalType: 'uint256[]',
334
+ name: 'allocations',
335
+ type: 'uint256[]',
336
+ },
337
+ {
338
+ internalType: 'uint256',
339
+ name: 'totalAllocation',
340
+ type: 'uint256',
341
+ },
342
+ {
343
+ internalType: 'uint16',
344
+ name: 'distributionIncentive',
345
+ type: 'uint16',
346
+ },
347
+ ],
348
+ internalType: 'struct SplitV2Lib.Split',
349
+ name: '_splitParams',
350
+ type: 'tuple',
351
+ },
352
+ {
353
+ internalType: 'address',
354
+ name: '_owner',
355
+ type: 'address',
356
+ },
357
+ ],
358
+ name: 'predictDeterministicAddress',
359
+ outputs: [
360
+ {
361
+ internalType: 'address',
362
+ name: '',
363
+ type: 'address',
364
+ },
365
+ ],
366
+ stateMutability: 'view',
367
+ type: 'function',
368
+ },
369
+ {
370
+ inputs: [
371
+ {
372
+ components: [
373
+ {
374
+ internalType: 'address[]',
375
+ name: 'recipients',
376
+ type: 'address[]',
377
+ },
378
+ {
379
+ internalType: 'uint256[]',
380
+ name: 'allocations',
381
+ type: 'uint256[]',
382
+ },
383
+ {
384
+ internalType: 'uint256',
385
+ name: 'totalAllocation',
386
+ type: 'uint256',
387
+ },
388
+ {
389
+ internalType: 'uint16',
390
+ name: 'distributionIncentive',
391
+ type: 'uint16',
392
+ },
393
+ ],
394
+ internalType: 'struct SplitV2Lib.Split',
395
+ name: '_splitParams',
396
+ type: 'tuple',
397
+ },
398
+ {
399
+ internalType: 'address',
400
+ name: '_owner',
401
+ type: 'address',
402
+ },
403
+ {
404
+ internalType: 'bytes32',
405
+ name: '_salt',
406
+ type: 'bytes32',
407
+ },
408
+ ],
409
+ name: 'predictDeterministicAddress',
410
+ outputs: [
411
+ {
412
+ internalType: 'address',
413
+ name: '',
414
+ type: 'address',
415
+ },
416
+ ],
417
+ stateMutability: 'view',
418
+ type: 'function',
419
+ },
420
+ ];
@@ -67,6 +67,25 @@ const validateOVMTotalSplitRecipients = (_, data) => {
67
67
  const splitPercentage = calculateTotalPercentage(data.principalSplitRecipients);
68
68
  return validateTotalPercentage(splitPercentage);
69
69
  };
70
+ const validateOVMRequestWithdrawalPayload = (_, data) => {
71
+ console.log(data, 'hanaaan dataaaa');
72
+ if (!data.pubKeys || !data.amounts) {
73
+ return false;
74
+ }
75
+ if (data.pubKeys.length !== data.amounts.length) {
76
+ return false;
77
+ }
78
+ // // Validate that all amounts are at least 1,000,000 gwei
79
+ // const minAmount = BigInt(1000000);
80
+ // for (const amountStr of data.amounts) {
81
+ // const minAmount = BigInt(1000000);
82
+ // const amount = BigInt(amountStr);
83
+ // if (amount < minAmount) {
84
+ // return false;
85
+ // }
86
+ // }
87
+ return true;
88
+ };
70
89
  const ajv = new ajv_1.default({
71
90
  allErrors: true,
72
91
  useDefaults: true,
@@ -100,6 +119,11 @@ ajv.addKeyword({
100
119
  validate: validateOVMTotalSplitRecipients,
101
120
  schemaType: 'boolean',
102
121
  });
122
+ ajv.addKeyword({
123
+ keyword: 'validateOVMRequestWithdrawalPayload',
124
+ validate: validateOVMRequestWithdrawalPayload,
125
+ schemaType: 'boolean',
126
+ });
103
127
  function validatePayload(data, schema) {
104
128
  var _a;
105
129
  const validate = ajv.compile(schema);