@obolnetwork/obol-sdk 2.7.0 → 2.8.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.
Files changed (56) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/abi/OVMFactory.js +620 -0
  3. package/dist/cjs/src/abi/splitV2FactoryAbi.js +420 -0
  4. package/dist/cjs/src/ajv.js +33 -6
  5. package/dist/cjs/src/bytecodes.js +10 -1
  6. package/dist/cjs/src/constants.js +71 -15
  7. package/dist/cjs/src/index.js +21 -9
  8. package/dist/cjs/src/schema.js +70 -1
  9. package/dist/cjs/src/splits/splitHelpers.js +188 -14
  10. package/dist/cjs/src/splits/splits.js +283 -0
  11. package/dist/cjs/src/types.js +0 -1
  12. package/dist/cjs/test/client/ajv.spec.js +269 -0
  13. package/dist/cjs/test/client/methods.spec.js +418 -0
  14. package/dist/cjs/test/fixtures.js +13 -1
  15. package/dist/cjs/test/splits/splits.spec.js +239 -0
  16. package/dist/esm/package.json +1 -1
  17. package/dist/esm/src/abi/OVMFactory.js +617 -0
  18. package/dist/esm/src/abi/splitV2FactoryAbi.js +417 -0
  19. package/dist/esm/src/ajv.js +33 -6
  20. package/dist/esm/src/bytecodes.js +9 -0
  21. package/dist/esm/src/constants.js +70 -15
  22. package/dist/esm/src/index.js +20 -9
  23. package/dist/esm/src/schema.js +70 -1
  24. package/dist/esm/src/splits/splitHelpers.js +182 -13
  25. package/dist/esm/src/splits/splits.js +279 -0
  26. package/dist/esm/src/types.js +0 -1
  27. package/dist/esm/test/client/ajv.spec.js +267 -0
  28. package/dist/esm/test/client/methods.spec.js +393 -0
  29. package/dist/esm/test/fixtures.js +12 -0
  30. package/dist/esm/test/splits/splits.spec.js +237 -0
  31. package/dist/types/src/abi/OVMFactory.d.ts +662 -0
  32. package/dist/types/src/abi/splitV2FactoryAbi.d.ts +60 -0
  33. package/dist/types/src/bytecodes.d.ts +9 -0
  34. package/dist/types/src/constants.d.ts +10 -21
  35. package/dist/types/src/exits/verificationHelpers.d.ts +1 -0
  36. package/dist/types/src/index.d.ts +7 -0
  37. package/dist/types/src/schema.d.ts +145 -0
  38. package/dist/types/src/splits/splitHelpers.d.ts +39 -2
  39. package/dist/types/src/splits/splits.d.ts +51 -0
  40. package/dist/types/src/types.d.ts +87 -2
  41. package/dist/types/src/verification/common.d.ts +1 -0
  42. package/dist/types/test/client/ajv.spec.d.ts +1 -0
  43. package/dist/types/test/client/methods.spec.d.ts +1 -0
  44. package/dist/types/test/fixtures.d.ts +10 -0
  45. package/dist/types/test/splits/splits.spec.d.ts +1 -0
  46. package/package.json +1 -1
  47. package/src/abi/OVMFactory.ts +617 -0
  48. package/src/abi/splitV2FactoryAbi.ts +417 -0
  49. package/src/ajv.ts +55 -13
  50. package/src/bytecodes.ts +19 -0
  51. package/src/constants.ts +84 -16
  52. package/src/index.ts +36 -15
  53. package/src/schema.ts +79 -0
  54. package/src/splits/splitHelpers.ts +373 -18
  55. package/src/splits/splits.ts +406 -0
  56. package/src/types.ts +100 -3
@@ -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
+ ];
@@ -19,18 +19,26 @@ exports.VALID_NON_COMPOUNDING_AMOUNTS = [
19
19
  (0, ethers_1.parseUnits)('1', 'gwei').toString(),
20
20
  (0, ethers_1.parseUnits)('32', 'gwei').toString(),
21
21
  ];
22
- // They dont see defaults set in schema
22
+ const calculateTotalPercentage = (recipients) => {
23
+ return recipients.reduce((acc, curr) => acc + curr.percentAllocation, 0);
24
+ };
25
+ const validateTotalPercentage = (totalPercentage) => {
26
+ return totalPercentage === 100;
27
+ };
28
+ const validateTotalPercentageWithRAF = (totalPercentage, rafPercentage) => {
29
+ return totalPercentage + rafPercentage === 100;
30
+ };
23
31
  const validateRewardsSplitRecipients = (_, data) => {
24
32
  var _a;
25
- const obolRAFSplit = (_a = data.ObolRAFSplit) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT;
26
- const splitPercentage = data.splitRecipients.reduce((acc, curr) => acc + curr.percentAllocation, 0);
27
- return splitPercentage + obolRAFSplit === 100;
33
+ const obolRAFSplit = (_a = data === null || data === void 0 ? void 0 : data.ObolRAFSplit) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT;
34
+ const splitPercentage = calculateTotalPercentage(data.splitRecipients);
35
+ return validateTotalPercentageWithRAF(splitPercentage, obolRAFSplit);
28
36
  };
29
37
  const validateTotalSplitRecipients = (_, data) => {
30
38
  var _a;
31
39
  const obolRAFSplit = (_a = data.ObolRAFSplit) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_RETROACTIVE_FUNDING_TOTAL_SPLIT;
32
- const splitPercentage = data.splitRecipients.reduce((acc, curr) => acc + curr.percentAllocation, 0);
33
- return splitPercentage + obolRAFSplit === 100;
40
+ const splitPercentage = calculateTotalPercentage(data.splitRecipients);
41
+ return validateTotalPercentageWithRAF(splitPercentage, obolRAFSplit);
34
42
  };
35
43
  const validateUniqueAddresses = (_, operators) => {
36
44
  if (!operators) {
@@ -50,6 +58,15 @@ const validateUniqueAddresses = (_, operators) => {
50
58
  const isUnique = uniqueAddresses.size === addresses.length;
51
59
  return isUnique;
52
60
  };
61
+ const validateOVMRewardsSplitRecipients = (_, data) => {
62
+ const obolRAFSplit = constants_1.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT;
63
+ const splitPercentage = calculateTotalPercentage(data.rewardSplitRecipients);
64
+ return validateTotalPercentageWithRAF(splitPercentage, obolRAFSplit);
65
+ };
66
+ const validateOVMTotalSplitRecipients = (_, data) => {
67
+ const splitPercentage = calculateTotalPercentage(data.principalSplitRecipients);
68
+ return validateTotalPercentage(splitPercentage);
69
+ };
53
70
  const ajv = new ajv_1.default({
54
71
  allErrors: true,
55
72
  useDefaults: true,
@@ -73,6 +90,16 @@ ajv.addKeyword({
73
90
  validate: validateUniqueAddresses,
74
91
  schemaType: 'boolean',
75
92
  });
93
+ ajv.addKeyword({
94
+ keyword: 'validateOVMRewardsSplitRecipients',
95
+ validate: validateOVMRewardsSplitRecipients,
96
+ schemaType: 'boolean',
97
+ });
98
+ ajv.addKeyword({
99
+ keyword: 'validateOVMTotalSplitRecipients',
100
+ validate: validateOVMTotalSplitRecipients,
101
+ schemaType: 'boolean',
102
+ });
76
103
  function validatePayload(data, schema) {
77
104
  var _a;
78
105
  const validate = ajv.compile(schema);