@obolnetwork/obol-sdk 2.11.4 → 2.11.5-rc.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 (144) hide show
  1. package/README.md +33 -0
  2. package/dist/browser/src/index.js +18280 -0
  3. package/dist/browser/src/index.js.map +1 -0
  4. package/dist/cjs/src/index.js +17470 -382
  5. package/dist/cjs/src/index.js.map +1 -0
  6. package/dist/esm/src/index.js +17437 -361
  7. package/dist/esm/src/index.js.map +1 -0
  8. package/dist/types/src/constants.d.ts +1 -2
  9. package/dist/types/src/eoa/eoaHelpers.d.ts +1 -1
  10. package/dist/types/src/exits/verificationHelpers.d.ts +0 -2
  11. package/dist/types/src/incentives/incentiveHelpers.d.ts +1 -1
  12. package/dist/types/src/splits/splitHelpers.d.ts +3 -3
  13. package/dist/types/src/utils.d.ts +2 -2
  14. package/dist/types/src/verification/common.d.ts +0 -2
  15. package/dist/types/src/verification/signature-validator.d.ts +4 -4
  16. package/dist/types/src/verification/v1.10.0.d.ts +1 -1
  17. package/dist/types/src/verification/v1.6.0.d.ts +1 -1
  18. package/dist/types/src/verification/v1.7.0.d.ts +1 -1
  19. package/dist/types/src/verification/v1.8.0.d.ts +1 -1
  20. package/dist/types/test/client/methods.spec.d.ts +17 -0
  21. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  22. package/dist/types/tsup.config.d.ts +2 -0
  23. package/package.json +96 -58
  24. package/dist/cjs/package.json +0 -139
  25. package/dist/cjs/src/abi/BatchDeposit.js +0 -120
  26. package/dist/cjs/src/abi/MerkleDistributorWithDeadline.js +0 -73
  27. package/dist/cjs/src/abi/Multicall3.js +0 -253
  28. package/dist/cjs/src/abi/OVM.js +0 -627
  29. package/dist/cjs/src/abi/OWR.js +0 -304
  30. package/dist/cjs/src/abi/SplitMain.js +0 -929
  31. package/dist/cjs/src/abi/splitV2FactoryAbi.js +0 -420
  32. package/dist/cjs/src/ajv.js +0 -136
  33. package/dist/cjs/src/base.js +0 -42
  34. package/dist/cjs/src/bytecodes.js +0 -19
  35. package/dist/cjs/src/constants.js +0 -272
  36. package/dist/cjs/src/eoa/eoa.js +0 -132
  37. package/dist/cjs/src/eoa/eoaHelpers.js +0 -82
  38. package/dist/cjs/src/errors.js +0 -11
  39. package/dist/cjs/src/exits/ethUtils.js +0 -57
  40. package/dist/cjs/src/exits/exit.js +0 -502
  41. package/dist/cjs/src/exits/verificationHelpers.js +0 -86
  42. package/dist/cjs/src/incentives/incentiveHelpers.js +0 -39
  43. package/dist/cjs/src/incentives/incentives.js +0 -119
  44. package/dist/cjs/src/schema.js +0 -352
  45. package/dist/cjs/src/services.js +0 -33
  46. package/dist/cjs/src/splits/splitHelpers.js +0 -571
  47. package/dist/cjs/src/splits/splits.js +0 -366
  48. package/dist/cjs/src/types.js +0 -29
  49. package/dist/cjs/src/utils.js +0 -77
  50. package/dist/cjs/src/verification/common.js +0 -355
  51. package/dist/cjs/src/verification/signature-validator.js +0 -73
  52. package/dist/cjs/src/verification/sszTypes.js +0 -69
  53. package/dist/cjs/src/verification/termsAndConditions.js +0 -40
  54. package/dist/cjs/src/verification/v1.10.0.js +0 -146
  55. package/dist/cjs/src/verification/v1.6.0.js +0 -149
  56. package/dist/cjs/src/verification/v1.7.0.js +0 -173
  57. package/dist/cjs/src/verification/v1.8.0.js +0 -196
  58. package/dist/cjs/test/client/ajv.spec.js +0 -320
  59. package/dist/cjs/test/client/methods.spec.js +0 -418
  60. package/dist/cjs/test/eoa/eoa.spec.js +0 -176
  61. package/dist/cjs/test/exit/ethUtils.spec.js +0 -83
  62. package/dist/cjs/test/exit/exit.spec.js +0 -399
  63. package/dist/cjs/test/exit/verificationHelpers.spec.js +0 -68
  64. package/dist/cjs/test/fixtures.js +0 -896
  65. package/dist/cjs/test/incentives/incentives.spec.js +0 -202
  66. package/dist/cjs/test/splits/splits.spec.js +0 -402
  67. package/dist/esm/package.json +0 -139
  68. package/dist/esm/src/abi/BatchDeposit.js +0 -117
  69. package/dist/esm/src/abi/MerkleDistributorWithDeadline.js +0 -70
  70. package/dist/esm/src/abi/Multicall3.js +0 -250
  71. package/dist/esm/src/abi/OVM.js +0 -624
  72. package/dist/esm/src/abi/OWR.js +0 -301
  73. package/dist/esm/src/abi/SplitMain.js +0 -926
  74. package/dist/esm/src/abi/splitV2FactoryAbi.js +0 -417
  75. package/dist/esm/src/ajv.js +0 -129
  76. package/dist/esm/src/base.js +0 -38
  77. package/dist/esm/src/bytecodes.js +0 -16
  78. package/dist/esm/src/constants.js +0 -238
  79. package/dist/esm/src/eoa/eoa.js +0 -128
  80. package/dist/esm/src/eoa/eoaHelpers.js +0 -77
  81. package/dist/esm/src/errors.js +0 -7
  82. package/dist/esm/src/exits/ethUtils.js +0 -52
  83. package/dist/esm/src/exits/exit.js +0 -475
  84. package/dist/esm/src/exits/verificationHelpers.js +0 -81
  85. package/dist/esm/src/incentives/incentiveHelpers.js +0 -34
  86. package/dist/esm/src/incentives/incentives.js +0 -115
  87. package/dist/esm/src/schema.js +0 -349
  88. package/dist/esm/src/services.js +0 -29
  89. package/dist/esm/src/splits/splitHelpers.js +0 -554
  90. package/dist/esm/src/splits/splits.js +0 -362
  91. package/dist/esm/src/types.js +0 -26
  92. package/dist/esm/src/utils.js +0 -68
  93. package/dist/esm/src/verification/common.js +0 -319
  94. package/dist/esm/src/verification/signature-validator.js +0 -64
  95. package/dist/esm/src/verification/sszTypes.js +0 -64
  96. package/dist/esm/src/verification/termsAndConditions.js +0 -33
  97. package/dist/esm/src/verification/v1.10.0.js +0 -140
  98. package/dist/esm/src/verification/v1.6.0.js +0 -142
  99. package/dist/esm/src/verification/v1.7.0.js +0 -166
  100. package/dist/esm/src/verification/v1.8.0.js +0 -189
  101. package/dist/esm/test/client/ajv.spec.js +0 -318
  102. package/dist/esm/test/client/methods.spec.js +0 -393
  103. package/dist/esm/test/eoa/eoa.spec.js +0 -174
  104. package/dist/esm/test/exit/ethUtils.spec.js +0 -81
  105. package/dist/esm/test/exit/exit.spec.js +0 -374
  106. package/dist/esm/test/exit/verificationHelpers.spec.js +0 -66
  107. package/dist/esm/test/fixtures.js +0 -893
  108. package/dist/esm/test/incentives/incentives.spec.js +0 -177
  109. package/dist/esm/test/splits/splits.spec.js +0 -400
  110. package/dist/types/src/verification/termsAndConditions.d.ts +0 -1
  111. package/src/abi/BatchDeposit.ts +0 -117
  112. package/src/abi/MerkleDistributorWithDeadline.ts +0 -70
  113. package/src/abi/Multicall3.ts +0 -250
  114. package/src/abi/OVM.ts +0 -624
  115. package/src/abi/OWR.ts +0 -302
  116. package/src/abi/SplitMain.ts +0 -927
  117. package/src/abi/splitV2FactoryAbi.ts +0 -417
  118. package/src/ajv.ts +0 -191
  119. package/src/base.ts +0 -54
  120. package/src/bytecodes.ts +0 -32
  121. package/src/constants.ts +0 -309
  122. package/src/eoa/eoa.ts +0 -153
  123. package/src/eoa/eoaHelpers.ts +0 -112
  124. package/src/errors.ts +0 -8
  125. package/src/exits/ethUtils.ts +0 -49
  126. package/src/exits/exit.ts +0 -661
  127. package/src/exits/verificationHelpers.ts +0 -110
  128. package/src/incentives/incentiveHelpers.ts +0 -55
  129. package/src/incentives/incentives.ts +0 -153
  130. package/src/index.ts +0 -614
  131. package/src/schema.ts +0 -376
  132. package/src/services.ts +0 -24
  133. package/src/splits/splitHelpers.ts +0 -1032
  134. package/src/splits/splits.ts +0 -504
  135. package/src/types.ts +0 -687
  136. package/src/utils.ts +0 -88
  137. package/src/verification/common.ts +0 -532
  138. package/src/verification/signature-validator.ts +0 -103
  139. package/src/verification/sszTypes.ts +0 -88
  140. package/src/verification/termsAndConditions.ts +0 -32
  141. package/src/verification/v1.10.0.ts +0 -245
  142. package/src/verification/v1.6.0.ts +0 -256
  143. package/src/verification/v1.7.0.ts +0 -309
  144. package/src/verification/v1.8.0.ts +0 -340
@@ -1,420 +0,0 @@
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
- ];
@@ -1,136 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validatePayload = exports.VALID_NON_COMPOUNDING_AMOUNTS = exports.VALID_DEPOSIT_AMOUNTS = void 0;
7
- const ajv_formats_1 = __importDefault(require("ajv-formats"));
8
- const ajv_keywords_1 = __importDefault(require("ajv-keywords"));
9
- const ethers_1 = require("ethers");
10
- const ajv_1 = __importDefault(require("ajv"));
11
- const constants_1 = require("./constants");
12
- exports.VALID_DEPOSIT_AMOUNTS = [
13
- (0, ethers_1.parseUnits)('1', 'gwei').toString(),
14
- (0, ethers_1.parseUnits)('32', 'gwei').toString(),
15
- (0, ethers_1.parseUnits)('8', 'gwei').toString(),
16
- (0, ethers_1.parseUnits)('256', 'gwei').toString(),
17
- ];
18
- exports.VALID_NON_COMPOUNDING_AMOUNTS = [
19
- (0, ethers_1.parseUnits)('1', 'gwei').toString(),
20
- (0, ethers_1.parseUnits)('32', 'gwei').toString(),
21
- ];
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
- };
31
- const validateRewardsSplitRecipients = (_, data) => {
32
- var _a;
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);
36
- };
37
- const validateTotalSplitRecipients = (_, data) => {
38
- var _a;
39
- const obolRAFSplit = (_a = data.ObolRAFSplit) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_RETROACTIVE_FUNDING_TOTAL_SPLIT;
40
- const splitPercentage = calculateTotalPercentage(data.splitRecipients);
41
- return validateTotalPercentageWithRAF(splitPercentage, obolRAFSplit);
42
- };
43
- const validateUniqueAddresses = (_, operators) => {
44
- if (!operators) {
45
- return false;
46
- }
47
- if (operators.length < 4) {
48
- return false;
49
- }
50
- if (operators.every(op => op.address === '')) {
51
- return true;
52
- }
53
- if (operators.some(op => op.address.length !== 42)) {
54
- return false;
55
- }
56
- const addresses = operators.map(op => op.address);
57
- const uniqueAddresses = new Set(addresses);
58
- const isUnique = uniqueAddresses.size === addresses.length;
59
- return isUnique;
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
- };
70
- const validateOVMRequestWithdrawalPayload = (_, data) => {
71
- if (!data.pubKeys || !data.amounts) {
72
- return false;
73
- }
74
- if (data.pubKeys.length !== data.amounts.length) {
75
- return false;
76
- }
77
- // // Validate that all amounts are at least 1,000,000 gwei
78
- // const minAmount = BigInt(1000000);
79
- // for (const amountStr of data.amounts) {
80
- // const minAmount = BigInt(1000000);
81
- // const amount = BigInt(amountStr);
82
- // if (amount < minAmount) {
83
- // return false;
84
- // }
85
- // }
86
- return true;
87
- };
88
- const ajv = new ajv_1.default({
89
- allErrors: true,
90
- useDefaults: true,
91
- strict: false,
92
- $data: true,
93
- });
94
- (0, ajv_formats_1.default)(ajv);
95
- (0, ajv_keywords_1.default)(ajv, ['patternRequired']);
96
- ajv.addKeyword({
97
- keyword: 'validateRewardsSplitRecipients',
98
- validate: validateRewardsSplitRecipients,
99
- schemaType: 'boolean',
100
- });
101
- ajv.addKeyword({
102
- keyword: 'validateTotalSplitRecipients',
103
- validate: validateTotalSplitRecipients,
104
- schemaType: 'boolean',
105
- });
106
- ajv.addKeyword({
107
- keyword: 'validateUniqueAddresses',
108
- validate: validateUniqueAddresses,
109
- schemaType: 'boolean',
110
- });
111
- ajv.addKeyword({
112
- keyword: 'validateOVMRewardsSplitRecipients',
113
- validate: validateOVMRewardsSplitRecipients,
114
- schemaType: 'boolean',
115
- });
116
- ajv.addKeyword({
117
- keyword: 'validateOVMTotalSplitRecipients',
118
- validate: validateOVMTotalSplitRecipients,
119
- schemaType: 'boolean',
120
- });
121
- ajv.addKeyword({
122
- keyword: 'validateOVMRequestWithdrawalPayload',
123
- validate: validateOVMRequestWithdrawalPayload,
124
- schemaType: 'boolean',
125
- });
126
- function validatePayload(data, schema) {
127
- var _a;
128
- const validate = ajv.compile(schema);
129
- const valid = validate(data);
130
- if (!valid) {
131
- const errors = (_a = validate.errors) === null || _a === void 0 ? void 0 : _a.map(e => `${e.instancePath} ${e.message}`).join(', ');
132
- throw new Error(`Validation failed: ${errors}`);
133
- }
134
- return data;
135
- }
136
- exports.validatePayload = validatePayload;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Base = void 0;
13
- // src/resources/base.ts
14
- const constants_js_1 = require("./constants.js");
15
- const types_js_1 = require("./types.js");
16
- class Base {
17
- constructor({ baseUrl = constants_js_1.DEFAULT_BASE_URL, chainId = constants_js_1.DEFAULT_CHAIN_ID, }) {
18
- this.baseUrl = baseUrl;
19
- this.chainId = chainId;
20
- this.fork_version = types_js_1.FORK_MAPPING[this.chainId];
21
- }
22
- request(endpoint, options) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const url = `${this.baseUrl}${endpoint}`;
25
- const config = Object.assign(Object.assign({}, options), { headers: Object.assign({ 'Content-Type': 'application/json', 'User-Agent': `Obol-SDK/${constants_js_1.SDK_VERSION}` }, options === null || options === void 0 ? void 0 : options.headers) });
26
- try {
27
- const response = yield fetch(url, config);
28
- if (response.ok) {
29
- return yield response.json();
30
- }
31
- else {
32
- const errorResponse = yield response.json();
33
- throw errorResponse;
34
- }
35
- }
36
- catch (e) {
37
- throw e;
38
- }
39
- });
40
- }
41
- }
42
- exports.Base = Base;