@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.
- package/README.md +33 -0
- package/dist/browser/src/index.js +18280 -0
- package/dist/browser/src/index.js.map +1 -0
- package/dist/cjs/src/index.js +17470 -382
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/esm/src/index.js +17437 -361
- package/dist/esm/src/index.js.map +1 -0
- package/dist/types/src/constants.d.ts +1 -2
- package/dist/types/src/eoa/eoaHelpers.d.ts +1 -1
- package/dist/types/src/exits/verificationHelpers.d.ts +0 -2
- package/dist/types/src/incentives/incentiveHelpers.d.ts +1 -1
- package/dist/types/src/splits/splitHelpers.d.ts +3 -3
- package/dist/types/src/utils.d.ts +2 -2
- package/dist/types/src/verification/common.d.ts +0 -2
- package/dist/types/src/verification/signature-validator.d.ts +4 -4
- package/dist/types/src/verification/v1.10.0.d.ts +1 -1
- package/dist/types/src/verification/v1.6.0.d.ts +1 -1
- package/dist/types/src/verification/v1.7.0.d.ts +1 -1
- package/dist/types/src/verification/v1.8.0.d.ts +1 -1
- package/dist/types/test/client/methods.spec.d.ts +17 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/tsup.config.d.ts +2 -0
- package/package.json +96 -58
- package/dist/cjs/package.json +0 -139
- package/dist/cjs/src/abi/BatchDeposit.js +0 -120
- package/dist/cjs/src/abi/MerkleDistributorWithDeadline.js +0 -73
- package/dist/cjs/src/abi/Multicall3.js +0 -253
- package/dist/cjs/src/abi/OVM.js +0 -627
- package/dist/cjs/src/abi/OWR.js +0 -304
- package/dist/cjs/src/abi/SplitMain.js +0 -929
- package/dist/cjs/src/abi/splitV2FactoryAbi.js +0 -420
- package/dist/cjs/src/ajv.js +0 -136
- package/dist/cjs/src/base.js +0 -42
- package/dist/cjs/src/bytecodes.js +0 -19
- package/dist/cjs/src/constants.js +0 -272
- package/dist/cjs/src/eoa/eoa.js +0 -132
- package/dist/cjs/src/eoa/eoaHelpers.js +0 -82
- package/dist/cjs/src/errors.js +0 -11
- package/dist/cjs/src/exits/ethUtils.js +0 -57
- package/dist/cjs/src/exits/exit.js +0 -502
- package/dist/cjs/src/exits/verificationHelpers.js +0 -86
- package/dist/cjs/src/incentives/incentiveHelpers.js +0 -39
- package/dist/cjs/src/incentives/incentives.js +0 -119
- package/dist/cjs/src/schema.js +0 -352
- package/dist/cjs/src/services.js +0 -33
- package/dist/cjs/src/splits/splitHelpers.js +0 -571
- package/dist/cjs/src/splits/splits.js +0 -366
- package/dist/cjs/src/types.js +0 -29
- package/dist/cjs/src/utils.js +0 -77
- package/dist/cjs/src/verification/common.js +0 -355
- package/dist/cjs/src/verification/signature-validator.js +0 -73
- package/dist/cjs/src/verification/sszTypes.js +0 -69
- package/dist/cjs/src/verification/termsAndConditions.js +0 -40
- package/dist/cjs/src/verification/v1.10.0.js +0 -146
- package/dist/cjs/src/verification/v1.6.0.js +0 -149
- package/dist/cjs/src/verification/v1.7.0.js +0 -173
- package/dist/cjs/src/verification/v1.8.0.js +0 -196
- package/dist/cjs/test/client/ajv.spec.js +0 -320
- package/dist/cjs/test/client/methods.spec.js +0 -418
- package/dist/cjs/test/eoa/eoa.spec.js +0 -176
- package/dist/cjs/test/exit/ethUtils.spec.js +0 -83
- package/dist/cjs/test/exit/exit.spec.js +0 -399
- package/dist/cjs/test/exit/verificationHelpers.spec.js +0 -68
- package/dist/cjs/test/fixtures.js +0 -896
- package/dist/cjs/test/incentives/incentives.spec.js +0 -202
- package/dist/cjs/test/splits/splits.spec.js +0 -402
- package/dist/esm/package.json +0 -139
- package/dist/esm/src/abi/BatchDeposit.js +0 -117
- package/dist/esm/src/abi/MerkleDistributorWithDeadline.js +0 -70
- package/dist/esm/src/abi/Multicall3.js +0 -250
- package/dist/esm/src/abi/OVM.js +0 -624
- package/dist/esm/src/abi/OWR.js +0 -301
- package/dist/esm/src/abi/SplitMain.js +0 -926
- package/dist/esm/src/abi/splitV2FactoryAbi.js +0 -417
- package/dist/esm/src/ajv.js +0 -129
- package/dist/esm/src/base.js +0 -38
- package/dist/esm/src/bytecodes.js +0 -16
- package/dist/esm/src/constants.js +0 -238
- package/dist/esm/src/eoa/eoa.js +0 -128
- package/dist/esm/src/eoa/eoaHelpers.js +0 -77
- package/dist/esm/src/errors.js +0 -7
- package/dist/esm/src/exits/ethUtils.js +0 -52
- package/dist/esm/src/exits/exit.js +0 -475
- package/dist/esm/src/exits/verificationHelpers.js +0 -81
- package/dist/esm/src/incentives/incentiveHelpers.js +0 -34
- package/dist/esm/src/incentives/incentives.js +0 -115
- package/dist/esm/src/schema.js +0 -349
- package/dist/esm/src/services.js +0 -29
- package/dist/esm/src/splits/splitHelpers.js +0 -554
- package/dist/esm/src/splits/splits.js +0 -362
- package/dist/esm/src/types.js +0 -26
- package/dist/esm/src/utils.js +0 -68
- package/dist/esm/src/verification/common.js +0 -319
- package/dist/esm/src/verification/signature-validator.js +0 -64
- package/dist/esm/src/verification/sszTypes.js +0 -64
- package/dist/esm/src/verification/termsAndConditions.js +0 -33
- package/dist/esm/src/verification/v1.10.0.js +0 -140
- package/dist/esm/src/verification/v1.6.0.js +0 -142
- package/dist/esm/src/verification/v1.7.0.js +0 -166
- package/dist/esm/src/verification/v1.8.0.js +0 -189
- package/dist/esm/test/client/ajv.spec.js +0 -318
- package/dist/esm/test/client/methods.spec.js +0 -393
- package/dist/esm/test/eoa/eoa.spec.js +0 -174
- package/dist/esm/test/exit/ethUtils.spec.js +0 -81
- package/dist/esm/test/exit/exit.spec.js +0 -374
- package/dist/esm/test/exit/verificationHelpers.spec.js +0 -66
- package/dist/esm/test/fixtures.js +0 -893
- package/dist/esm/test/incentives/incentives.spec.js +0 -177
- package/dist/esm/test/splits/splits.spec.js +0 -400
- package/dist/types/src/verification/termsAndConditions.d.ts +0 -1
- package/src/abi/BatchDeposit.ts +0 -117
- package/src/abi/MerkleDistributorWithDeadline.ts +0 -70
- package/src/abi/Multicall3.ts +0 -250
- package/src/abi/OVM.ts +0 -624
- package/src/abi/OWR.ts +0 -302
- package/src/abi/SplitMain.ts +0 -927
- package/src/abi/splitV2FactoryAbi.ts +0 -417
- package/src/ajv.ts +0 -191
- package/src/base.ts +0 -54
- package/src/bytecodes.ts +0 -32
- package/src/constants.ts +0 -309
- package/src/eoa/eoa.ts +0 -153
- package/src/eoa/eoaHelpers.ts +0 -112
- package/src/errors.ts +0 -8
- package/src/exits/ethUtils.ts +0 -49
- package/src/exits/exit.ts +0 -661
- package/src/exits/verificationHelpers.ts +0 -110
- package/src/incentives/incentiveHelpers.ts +0 -55
- package/src/incentives/incentives.ts +0 -153
- package/src/index.ts +0 -614
- package/src/schema.ts +0 -376
- package/src/services.ts +0 -24
- package/src/splits/splitHelpers.ts +0 -1032
- package/src/splits/splits.ts +0 -504
- package/src/types.ts +0 -687
- package/src/utils.ts +0 -88
- package/src/verification/common.ts +0 -532
- package/src/verification/signature-validator.ts +0 -103
- package/src/verification/sszTypes.ts +0 -88
- package/src/verification/termsAndConditions.ts +0 -32
- package/src/verification/v1.10.0.ts +0 -245
- package/src/verification/v1.6.0.ts +0 -256
- package/src/verification/v1.7.0.ts +0 -309
- package/src/verification/v1.8.0.ts +0 -340
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ajv_1 = require("../../src/ajv");
|
|
4
|
-
const schema_1 = require("../../src/schema");
|
|
5
|
-
const fixtures_1 = require("../fixtures");
|
|
6
|
-
describe('validatePayload - OVM Schemas', () => {
|
|
7
|
-
describe('ovmRewardsSplitPayloadSchema', () => {
|
|
8
|
-
const validRewardsSplitPayload = {
|
|
9
|
-
rewardSplitRecipients: [
|
|
10
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
11
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
12
|
-
],
|
|
13
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
14
|
-
splitOwnerAddress: fixtures_1.TEST_ADDRESSES.SPLIT_OWNER,
|
|
15
|
-
principalRecipient: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT,
|
|
16
|
-
distributorFeePercent: 0,
|
|
17
|
-
};
|
|
18
|
-
it('should validate a valid rewards split payload', () => {
|
|
19
|
-
const result = (0, ajv_1.validatePayload)(validRewardsSplitPayload, schema_1.ovmRewardsSplitPayloadSchema);
|
|
20
|
-
expect(result).toEqual(validRewardsSplitPayload);
|
|
21
|
-
});
|
|
22
|
-
it('should validate rewards split payload with default values', () => {
|
|
23
|
-
const payloadWithoutDefaults = {
|
|
24
|
-
rewardSplitRecipients: [
|
|
25
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
26
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
27
|
-
],
|
|
28
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
29
|
-
principalRecipient: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT,
|
|
30
|
-
};
|
|
31
|
-
const result = (0, ajv_1.validatePayload)(payloadWithoutDefaults, schema_1.ovmRewardsSplitPayloadSchema);
|
|
32
|
-
expect(result).toEqual(Object.assign(Object.assign({}, payloadWithoutDefaults), { splitOwnerAddress: fixtures_1.TEST_ADDRESSES.ZERO_ADDRESS, principalThreshold: 16, distributorFeePercent: 0 }));
|
|
33
|
-
});
|
|
34
|
-
it('should throw error when rewardSplitRecipients total percentage is not 99%', () => {
|
|
35
|
-
const invalidPayload = Object.assign(Object.assign({}, validRewardsSplitPayload), { rewardSplitRecipients: [
|
|
36
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
37
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 40 }, // Total: 90%
|
|
38
|
-
] });
|
|
39
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmRewardsSplitPayloadSchema)).toThrow('Validation failed: must pass "validateOVMRewardsSplitRecipients" keyword validation');
|
|
40
|
-
});
|
|
41
|
-
it('should throw error when rewardSplitRecipients total percentage exceeds 99%', () => {
|
|
42
|
-
const invalidPayload = Object.assign(Object.assign({}, validRewardsSplitPayload), { rewardSplitRecipients: [
|
|
43
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 60 },
|
|
44
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 50 }, // Total: 110%
|
|
45
|
-
] });
|
|
46
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmRewardsSplitPayloadSchema)).toThrow('Validation failed: must pass "validateOVMRewardsSplitRecipients" keyword validation');
|
|
47
|
-
});
|
|
48
|
-
it('should throw error when rewardSplitRecipients is empty', () => {
|
|
49
|
-
const invalidPayload = Object.assign(Object.assign({}, validRewardsSplitPayload), { rewardSplitRecipients: [] });
|
|
50
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmRewardsSplitPayloadSchema)).toThrow('Validation failed: must pass "validateOVMRewardsSplitRecipients" keyword validation');
|
|
51
|
-
});
|
|
52
|
-
it('should throw error when rewardSplitRecipients has invalid address format', () => {
|
|
53
|
-
const invalidPayload = Object.assign(Object.assign({}, validRewardsSplitPayload), { rewardSplitRecipients: [
|
|
54
|
-
{ address: 'invalid-address', percentAllocation: 50 },
|
|
55
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
56
|
-
] });
|
|
57
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmRewardsSplitPayloadSchema)).toThrow('Validation failed: /rewardSplitRecipients/0/address must match pattern');
|
|
58
|
-
});
|
|
59
|
-
it('should throw error when OVMOwnerAddress is missing', () => {
|
|
60
|
-
const invalidPayload = {
|
|
61
|
-
rewardSplitRecipients: validRewardsSplitPayload.rewardSplitRecipients,
|
|
62
|
-
principalRecipient: validRewardsSplitPayload.principalRecipient,
|
|
63
|
-
};
|
|
64
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmRewardsSplitPayloadSchema)).toThrow("Validation failed: must have required property 'OVMOwnerAddress'");
|
|
65
|
-
});
|
|
66
|
-
it('should throw error when principalRecipient is missing', () => {
|
|
67
|
-
const invalidPayload = {
|
|
68
|
-
rewardSplitRecipients: validRewardsSplitPayload.rewardSplitRecipients,
|
|
69
|
-
OVMOwnerAddress: validRewardsSplitPayload.OVMOwnerAddress,
|
|
70
|
-
};
|
|
71
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmRewardsSplitPayloadSchema)).toThrow("Validation failed: must have required property 'principalRecipient'");
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('ovmTotalSplitPayloadSchema', () => {
|
|
75
|
-
const validTotalSplitPayload = {
|
|
76
|
-
rewardSplitRecipients: [
|
|
77
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
78
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
79
|
-
],
|
|
80
|
-
principalSplitRecipients: [
|
|
81
|
-
{
|
|
82
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
83
|
-
percentAllocation: 60,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
87
|
-
percentAllocation: 40,
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
91
|
-
splitOwnerAddress: fixtures_1.TEST_ADDRESSES.SPLIT_OWNER,
|
|
92
|
-
distributorFeePercent: 0,
|
|
93
|
-
};
|
|
94
|
-
it('should validate a valid total split payload', () => {
|
|
95
|
-
const result = (0, ajv_1.validatePayload)(validTotalSplitPayload, schema_1.ovmTotalSplitPayloadSchema);
|
|
96
|
-
expect(result).toEqual(validTotalSplitPayload);
|
|
97
|
-
});
|
|
98
|
-
it('should validate total split payload with default values', () => {
|
|
99
|
-
const payloadWithoutDefaults = {
|
|
100
|
-
rewardSplitRecipients: [
|
|
101
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
102
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 49 },
|
|
103
|
-
],
|
|
104
|
-
principalSplitRecipients: [
|
|
105
|
-
{
|
|
106
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
107
|
-
percentAllocation: 60,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
111
|
-
percentAllocation: 40,
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
115
|
-
};
|
|
116
|
-
const result = (0, ajv_1.validatePayload)(payloadWithoutDefaults, schema_1.ovmTotalSplitPayloadSchema);
|
|
117
|
-
expect(result).toEqual(Object.assign(Object.assign({}, payloadWithoutDefaults), { splitOwnerAddress: fixtures_1.TEST_ADDRESSES.ZERO_ADDRESS, principalThreshold: 16, distributorFeePercent: 0 }));
|
|
118
|
-
});
|
|
119
|
-
it('should throw error when rewardSplitRecipients total percentage is not 99%', () => {
|
|
120
|
-
const invalidPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { rewardSplitRecipients: [
|
|
121
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 50 },
|
|
122
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2, percentAllocation: 40 }, // Total: 90%
|
|
123
|
-
] });
|
|
124
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmTotalSplitPayloadSchema)).toThrow('Validation failed: must pass "validateOVMRewardsSplitRecipients" keyword validation');
|
|
125
|
-
});
|
|
126
|
-
it('should throw error when principalSplitRecipients total percentage is not 100%', () => {
|
|
127
|
-
const invalidPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { principalSplitRecipients: [
|
|
128
|
-
{
|
|
129
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
130
|
-
percentAllocation: 60,
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
134
|
-
percentAllocation: 30,
|
|
135
|
-
}, // Total: 90%
|
|
136
|
-
] });
|
|
137
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmTotalSplitPayloadSchema)).toThrow('Validation failed: must pass "validateOVMTotalSplitRecipients" keyword validation');
|
|
138
|
-
});
|
|
139
|
-
it('should throw error when principalSplitRecipients total percentage exceeds 100%', () => {
|
|
140
|
-
const invalidPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { principalSplitRecipients: [
|
|
141
|
-
{
|
|
142
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
143
|
-
percentAllocation: 70,
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
147
|
-
percentAllocation: 40,
|
|
148
|
-
}, // Total: 110%
|
|
149
|
-
] });
|
|
150
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmTotalSplitPayloadSchema)).toThrow('Validation failed: must pass "validateOVMTotalSplitRecipients" keyword validation');
|
|
151
|
-
});
|
|
152
|
-
it('should throw error when principalSplitRecipients is empty', () => {
|
|
153
|
-
const invalidPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { principalSplitRecipients: [] });
|
|
154
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmTotalSplitPayloadSchema)).toThrow('Validation failed: must pass "validateOVMTotalSplitRecipients" keyword validation');
|
|
155
|
-
});
|
|
156
|
-
it('should throw error when principalSplitRecipients has invalid address format', () => {
|
|
157
|
-
const invalidPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { principalSplitRecipients: [
|
|
158
|
-
{ address: 'invalid-address', percentAllocation: 60 },
|
|
159
|
-
{
|
|
160
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
161
|
-
percentAllocation: 40,
|
|
162
|
-
},
|
|
163
|
-
] });
|
|
164
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmTotalSplitPayloadSchema)).toThrow('Validation failed: /principalSplitRecipients/0/address must match pattern');
|
|
165
|
-
});
|
|
166
|
-
it('should throw error when OVMOwnerAddress is missing', () => {
|
|
167
|
-
const invalidPayload = {
|
|
168
|
-
rewardSplitRecipients: validTotalSplitPayload.rewardSplitRecipients,
|
|
169
|
-
principalSplitRecipients: validTotalSplitPayload.principalSplitRecipients,
|
|
170
|
-
};
|
|
171
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmTotalSplitPayloadSchema)).toThrow("Validation failed: must have required property 'OVMOwnerAddress'");
|
|
172
|
-
});
|
|
173
|
-
it('should throw error when principalThreshold is less than 16', () => {
|
|
174
|
-
const invalidPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { principalThreshold: 15 });
|
|
175
|
-
expect(() => (0, ajv_1.validatePayload)(invalidPayload, schema_1.ovmTotalSplitPayloadSchema)).toThrow('Validation failed: /principalThreshold must be >= 16');
|
|
176
|
-
});
|
|
177
|
-
it('should validate when principalThreshold is exactly 16', () => {
|
|
178
|
-
const validPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { principalThreshold: 16 });
|
|
179
|
-
const result = (0, ajv_1.validatePayload)(validPayload, schema_1.ovmTotalSplitPayloadSchema);
|
|
180
|
-
expect(result).toEqual(validPayload);
|
|
181
|
-
});
|
|
182
|
-
it('should validate when principalThreshold is greater than 16', () => {
|
|
183
|
-
const validPayload = Object.assign(Object.assign({}, validTotalSplitPayload), { principalThreshold: 20 });
|
|
184
|
-
const result = (0, ajv_1.validatePayload)(validPayload, schema_1.ovmTotalSplitPayloadSchema);
|
|
185
|
-
expect(result).toEqual(validPayload);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
describe('Edge cases and boundary conditions', () => {
|
|
189
|
-
it('should handle decimal percentages correctly for rewards split', () => {
|
|
190
|
-
const payload = {
|
|
191
|
-
rewardSplitRecipients: [
|
|
192
|
-
{
|
|
193
|
-
address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1,
|
|
194
|
-
percentAllocation: 49.5,
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2,
|
|
198
|
-
percentAllocation: 49.5,
|
|
199
|
-
},
|
|
200
|
-
],
|
|
201
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
202
|
-
principalRecipient: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT,
|
|
203
|
-
};
|
|
204
|
-
const result = (0, ajv_1.validatePayload)(payload, schema_1.ovmRewardsSplitPayloadSchema);
|
|
205
|
-
expect(result).toEqual(Object.assign(Object.assign({}, payload), { splitOwnerAddress: fixtures_1.TEST_ADDRESSES.ZERO_ADDRESS, principalThreshold: 16, distributorFeePercent: 0 }));
|
|
206
|
-
});
|
|
207
|
-
it('should handle decimal percentages correctly for total split', () => {
|
|
208
|
-
const payload = {
|
|
209
|
-
rewardSplitRecipients: [
|
|
210
|
-
{
|
|
211
|
-
address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1,
|
|
212
|
-
percentAllocation: 49.5,
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2,
|
|
216
|
-
percentAllocation: 49.5,
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
principalSplitRecipients: [
|
|
220
|
-
{
|
|
221
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
222
|
-
percentAllocation: 60.5,
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_2,
|
|
226
|
-
percentAllocation: 39.5,
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
230
|
-
};
|
|
231
|
-
const result = (0, ajv_1.validatePayload)(payload, schema_1.ovmTotalSplitPayloadSchema);
|
|
232
|
-
expect(result).toEqual(Object.assign(Object.assign({}, payload), { splitOwnerAddress: fixtures_1.TEST_ADDRESSES.ZERO_ADDRESS, principalThreshold: 16, distributorFeePercent: 0 }));
|
|
233
|
-
});
|
|
234
|
-
it('should handle single recipient with 99% allocation for rewards split', () => {
|
|
235
|
-
const payload = {
|
|
236
|
-
rewardSplitRecipients: [
|
|
237
|
-
{ address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1, percentAllocation: 99 },
|
|
238
|
-
],
|
|
239
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
240
|
-
principalRecipient: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT,
|
|
241
|
-
};
|
|
242
|
-
const result = (0, ajv_1.validatePayload)(payload, schema_1.ovmRewardsSplitPayloadSchema);
|
|
243
|
-
expect(result).toEqual(Object.assign(Object.assign({}, payload), { splitOwnerAddress: fixtures_1.TEST_ADDRESSES.ZERO_ADDRESS, principalThreshold: 16, distributorFeePercent: 0 }));
|
|
244
|
-
});
|
|
245
|
-
it('should handle single recipient with 100% allocation for total split', () => {
|
|
246
|
-
const payload = {
|
|
247
|
-
rewardSplitRecipients: [
|
|
248
|
-
{
|
|
249
|
-
address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_1,
|
|
250
|
-
percentAllocation: 49.5,
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
address: fixtures_1.TEST_ADDRESSES.REWARD_RECIPIENT_2,
|
|
254
|
-
percentAllocation: 49.5,
|
|
255
|
-
},
|
|
256
|
-
],
|
|
257
|
-
principalSplitRecipients: [
|
|
258
|
-
{
|
|
259
|
-
address: fixtures_1.TEST_ADDRESSES.PRINCIPAL_RECIPIENT_1,
|
|
260
|
-
percentAllocation: 100,
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
OVMOwnerAddress: fixtures_1.TEST_ADDRESSES.OVM_OWNER,
|
|
264
|
-
};
|
|
265
|
-
const result = (0, ajv_1.validatePayload)(payload, schema_1.ovmTotalSplitPayloadSchema);
|
|
266
|
-
expect(result).toEqual(Object.assign(Object.assign({}, payload), { splitOwnerAddress: fixtures_1.TEST_ADDRESSES.ZERO_ADDRESS, principalThreshold: 16, distributorFeePercent: 0 }));
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
describe('ovmRequestWithdrawalPayloadSchema', () => {
|
|
271
|
-
const validPayload = {
|
|
272
|
-
ovmAddress: '0x1234567890123456789012345678901234567890',
|
|
273
|
-
pubKeys: [
|
|
274
|
-
'0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
|
|
275
|
-
],
|
|
276
|
-
amounts: ['32000000000'],
|
|
277
|
-
withdrawalFees: '1',
|
|
278
|
-
};
|
|
279
|
-
it('should throw error when OVM address is missing', () => {
|
|
280
|
-
const payload = {
|
|
281
|
-
pubKeys: validPayload.pubKeys,
|
|
282
|
-
amounts: validPayload.amounts,
|
|
283
|
-
};
|
|
284
|
-
expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow("Validation failed: must have required property 'ovmAddress'");
|
|
285
|
-
});
|
|
286
|
-
it('should throw error when OVM address is invalid', () => {
|
|
287
|
-
const payload = {
|
|
288
|
-
ovmAddress: '0x123', // Too short
|
|
289
|
-
pubKeys: validPayload.pubKeys,
|
|
290
|
-
amounts: validPayload.amounts,
|
|
291
|
-
};
|
|
292
|
-
expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: must have required property \'withdrawalFees\', /ovmAddress must match pattern "^0x[a-fA-F0-9]{40}$"');
|
|
293
|
-
});
|
|
294
|
-
it('should throw error when number of public keys does not match number of amounts', () => {
|
|
295
|
-
const payload = {
|
|
296
|
-
ovmAddress: validPayload.ovmAddress,
|
|
297
|
-
pubKeys: validPayload.pubKeys,
|
|
298
|
-
amounts: ['32000000000', '16000000000'], // 2 amounts, 1 pubKey
|
|
299
|
-
withdrawalFees: validPayload.withdrawalFees,
|
|
300
|
-
};
|
|
301
|
-
expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: must pass "validateOVMRequestWithdrawalPayload" keyword validation');
|
|
302
|
-
});
|
|
303
|
-
it('should throw error when withdrawalFees is missing', () => {
|
|
304
|
-
const payload = {
|
|
305
|
-
ovmAddress: validPayload.ovmAddress,
|
|
306
|
-
pubKeys: validPayload.pubKeys,
|
|
307
|
-
amounts: validPayload.amounts,
|
|
308
|
-
};
|
|
309
|
-
expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow("Validation failed: must have required property 'withdrawalFees'");
|
|
310
|
-
});
|
|
311
|
-
it('should throw error when withdrawalFees is invalid', () => {
|
|
312
|
-
const payload = {
|
|
313
|
-
ovmAddress: validPayload.ovmAddress,
|
|
314
|
-
pubKeys: validPayload.pubKeys,
|
|
315
|
-
amounts: validPayload.amounts,
|
|
316
|
-
withdrawalFees: 'invalid',
|
|
317
|
-
};
|
|
318
|
-
expect(() => (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema)).toThrow('Validation failed: /withdrawalFees must match pattern "^[0-9]+$"');
|
|
319
|
-
});
|
|
320
|
-
});
|