@obolnetwork/obol-sdk 2.4.6 → 2.5.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.
- package/dist/cjs/package.json +3 -1
- package/dist/cjs/src/ajv.js +67 -41
- package/dist/cjs/src/constants.js +1 -1
- package/dist/cjs/src/index.js +25 -27
- package/dist/cjs/src/schema.js +50 -23
- package/dist/cjs/src/verification/v1.8.0.js +18 -0
- package/dist/cjs/test/fixtures.js +125 -17
- package/dist/cjs/test/methods.test.js +36 -42
- package/dist/esm/package.json +3 -1
- package/dist/esm/src/ajv.js +66 -40
- package/dist/esm/src/constants.js +1 -1
- package/dist/esm/src/index.js +26 -28
- package/dist/esm/src/schema.js +50 -23
- package/dist/esm/src/verification/v1.8.0.js +18 -0
- package/dist/esm/test/fixtures.js +124 -16
- package/dist/esm/test/methods.test.js +37 -43
- package/dist/types/src/ajv.d.ts +3 -2
- package/dist/types/src/constants.d.ts +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/schema.d.ts +40 -8
- package/dist/types/src/types.d.ts +8 -2
- package/dist/types/test/fixtures.d.ts +78 -11
- package/package.json +3 -1
- package/src/ajv.ts +91 -52
- package/src/constants.ts +1 -1
- package/src/index.ts +37 -35
- package/src/schema.ts +45 -22
- package/src/types.ts +11 -2
- package/src/verification/v1.8.0.ts +24 -0
|
@@ -170,22 +170,6 @@ export const clusterLockV1X7 = {
|
|
|
170
170
|
],
|
|
171
171
|
};
|
|
172
172
|
// v1.8.0
|
|
173
|
-
export const clusterConfigV1X8 = {
|
|
174
|
-
name: 'testSDK',
|
|
175
|
-
operators: [
|
|
176
|
-
{ address: '0xC35CfCd67b9C27345a54EDEcC1033F2284148c81' },
|
|
177
|
-
{ address: '0x33807D6F1DCe44b9C599fFE03640762A6F08C496' },
|
|
178
|
-
{ address: '0xc6e76F72Ea672FAe05C357157CfC37720F0aF26f' },
|
|
179
|
-
{ address: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966' },
|
|
180
|
-
],
|
|
181
|
-
validators: [
|
|
182
|
-
{
|
|
183
|
-
fee_recipient_address: '0x3CD4958e76C317abcEA19faDd076348808424F99',
|
|
184
|
-
withdrawal_address: '0xE0C5ceA4D3869F156717C66E188Ae81C80914a6e',
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
deposit_amounts: ['8000000000', '16000000000', '8000000000'],
|
|
188
|
-
};
|
|
189
173
|
export const clusterLockV1X8 = {
|
|
190
174
|
cluster_definition: {
|
|
191
175
|
name: 'xxxx',
|
|
@@ -507,6 +491,40 @@ export const clusterLockWithSafe = {
|
|
|
507
491
|
'0x4067921a5257efe4ceb103f2129faaa7a502781157b3b54e5efca559c558c2b43b89f30962e87df88fbf62250049a31888fcd62735d54b7553e5dc75c3b6ae0901',
|
|
508
492
|
],
|
|
509
493
|
};
|
|
494
|
+
export const clusterConfigV1X10 = {
|
|
495
|
+
name: 'testSDK',
|
|
496
|
+
operators: [
|
|
497
|
+
{ address: '0xC35CfCd67b9C27345a54EDEcC1033F2284148c81' },
|
|
498
|
+
{ address: '0x33807D6F1DCe44b9C599fFE03640762A6F08C496' },
|
|
499
|
+
{ address: '0xc6e76F72Ea672FAe05C357157CfC37720F0aF26f' },
|
|
500
|
+
{ address: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966' },
|
|
501
|
+
],
|
|
502
|
+
validators: [
|
|
503
|
+
{
|
|
504
|
+
fee_recipient_address: '0x3CD4958e76C317abcEA19faDd076348808424F99',
|
|
505
|
+
withdrawal_address: '0xE0C5ceA4D3869F156717C66E188Ae81C80914a6e',
|
|
506
|
+
},
|
|
507
|
+
],
|
|
508
|
+
deposit_amounts: ['8000000000', '32000000000', '8000000000'],
|
|
509
|
+
compounding: true,
|
|
510
|
+
target_gas_limit: 36000000,
|
|
511
|
+
consensus_protocol: '',
|
|
512
|
+
};
|
|
513
|
+
export const soloClusterConfigV1X10 = {
|
|
514
|
+
name: 'testSDK',
|
|
515
|
+
operators: [
|
|
516
|
+
{ address: '' },
|
|
517
|
+
{ address: '' },
|
|
518
|
+
{ address: '' },
|
|
519
|
+
{ address: '' },
|
|
520
|
+
],
|
|
521
|
+
validators: [
|
|
522
|
+
{
|
|
523
|
+
fee_recipient_address: '0x3CD4958e76C317abcEA19faDd076348808424F99',
|
|
524
|
+
withdrawal_address: '0xE0C5ceA4D3869F156717C66E188Ae81C80914a6e',
|
|
525
|
+
},
|
|
526
|
+
],
|
|
527
|
+
};
|
|
510
528
|
export const clusterLockV1X10 = {
|
|
511
529
|
cluster_definition: {
|
|
512
530
|
name: 'test',
|
|
@@ -771,3 +789,93 @@ export const clusterLockWithCompoundingWithdrawals = {
|
|
|
771
789
|
'0x3e2548c3c35df90bd7af34f9cc439e7ec4e4fa5619f74ca393bde8e05942dfde0c2e5d95249f478533fe11581b794e5de55446452e4dd1648c33b319a987461701',
|
|
772
790
|
],
|
|
773
791
|
};
|
|
792
|
+
export const clusterLockWithCompoundingWithdrawalss = {
|
|
793
|
+
cluster_definition: {
|
|
794
|
+
name: 'test v1.10.0',
|
|
795
|
+
creator: {
|
|
796
|
+
address: '0xc6e76F72Ea672FAe05C357157CfC37720F0aF26f',
|
|
797
|
+
config_signature: '0x62b609c3a56439fe60785895d60a36912b85d50c14a41fce36795c65d6263bb207467a4d4be7dc292bfd1c636332b1c409feaec6ce2ae9488ae1ad622264a7a81c',
|
|
798
|
+
},
|
|
799
|
+
operators: [
|
|
800
|
+
{
|
|
801
|
+
address: '0xc6e76F72Ea672FAe05C357157CfC37720F0aF26f',
|
|
802
|
+
enr: 'enr:-HW4QLlrtMjFLGkFT1bwdGbvZQlH8hLi0M2g44JAxEYP3BZmYpcsy9Q56HPPD87fMucjvLv4-obEFacpsg0ehRilbHeAgmlkgnY0iXNlY3AyNTZrMaEDRaa5o2aSgqyFq_ERZcQTztrOij1mFtXX1bJuVI6ieak',
|
|
803
|
+
config_signature: '0x58c31787cf1f9680f736713f4ce039c8bf69467e5128edb2888d380451bd757367665c1ba04dc7656eb0b77eac39f776780710e603372f2a41bd40f4d297c7fa1c',
|
|
804
|
+
enr_signature: '0x4df48b8fc16deb2441022a019b72976524f4ce3dd674ee70561fb9eb52985d3b0d9528532d3e5be7a44548be27e9e96c5358b9f6756c7c7a97e2126f9c2c9b071b',
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
address: '0xa084D9095BcBdFe8014B68fa52D73DCeb16C5129',
|
|
808
|
+
enr: 'enr:-Iu4QNbiUUUwT18LynBbVPJhNxvzQsaSpUr40mQTWscnZaqKb6vAlvV8j-eDDR3E0wjMQumGRbGm2IAb5_k4bVWJiVGAgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPOiodUji0ohgJb5sNK1hgv8g6xO5_znZz3NkkBkyYyKIN0Y3CCDhqDdWRwgg4u',
|
|
809
|
+
config_signature: '0xc76b2f067a65c9cc6110ab99471b03f47545581e79164758114c98825d5440891843790ce92ca24ee7b3568b839cc88c2b3824587f8f260fca15bb852f69a3af1c',
|
|
810
|
+
enr_signature: '0x49e2a07424e412ed904fd47381c36203cb8c5575a31ba260b3f8420dc89a86fc0d7fbc087160a60690be2f6fb212423d467e212494992ab9a72f10319779a2cc1c',
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
address: '0xb1D2740Ee055693FE21bbCfc780729472C3f6B84',
|
|
814
|
+
enr: 'enr:-Iu4QJyserRukhG0Vgi2csu7GjpHYUGufNEbZ8Q7ZBrcZUb0KqpL5QzHonkh1xxHlxatTxrIcX_IS5J3SEWR_sa0ptGAgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQMAUgEqczOjevyculnUIofhCj0DkgJudErM7qCYIvIkzIN0Y3CCDhqDdWRwgg4u',
|
|
815
|
+
config_signature: '0x8b0cea21e065d25faa3b9d3b9e8f497d3c2d8baf800a1c5ecbde64c041745b7e15131d28f7ab917bdcead3225dda16987f2fd160546e087987cbb483bd187cb11b',
|
|
816
|
+
enr_signature: '0x805f38269379087168900a37569f1108b9d4253a03c2650a4e8d69228cb4cc616b94988e4b218a8d47113063270c4a894e873a5070c7ef0f4d44ee3359eec51b1b',
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
address: '0x69D39e2d0Fb6fb80CCd5d49a75416cB7d1BC6DB6',
|
|
820
|
+
enr: 'enr:-HW4QKJTwXC6Chw6zbnA3HFZi6Jo0DkIgjKy4eUBpsSOGnAeWE6ChEjEyk_6R6Qrm7jI-iqfs3_HYxiKde8vFgvHHrCAgmlkgnY0iXNlY3AyNTZrMaECfFKQH4spdZCHqrKVz1Q02xYla6J_RQECDNNYBRWdzv8',
|
|
821
|
+
config_signature: '0x9e21c2308738fb17b38d1850b83312c25306c0bcbd575e0417e311d5fc1697807291328a299859df70ac3efb402207067dbb0559bc4fef4e6ca2fd77fa4c2a321c',
|
|
822
|
+
enr_signature: '0x3a6590600b2dc27b042aabd3fa4654f1064b42e8f850d1fac13394a6786463be2a2727623e4e9e98453113f7024e73d652d1c6288ef82ede7acbb08e25ff00751b',
|
|
823
|
+
},
|
|
824
|
+
],
|
|
825
|
+
uuid: '34036642-9d45-4b6f-817d-f8d5aa0110d4',
|
|
826
|
+
version: 'v1.10.0',
|
|
827
|
+
timestamp: '2025-04-03T17:27:27.767Z',
|
|
828
|
+
num_validators: 1,
|
|
829
|
+
threshold: 3,
|
|
830
|
+
validators: [
|
|
831
|
+
{
|
|
832
|
+
fee_recipient_address: '0xc6e76F72Ea672FAe05C357157CfC37720F0aF26f',
|
|
833
|
+
withdrawal_address: '0xc6e76F72Ea672FAe05C357157CfC37720F0aF26f',
|
|
834
|
+
},
|
|
835
|
+
],
|
|
836
|
+
dkg_algorithm: 'default',
|
|
837
|
+
fork_version: '0x10000910',
|
|
838
|
+
deposit_amounts: ['32000000000'],
|
|
839
|
+
consensus_protocol: 'abft',
|
|
840
|
+
target_gas_limit: 30000000,
|
|
841
|
+
compounding: true,
|
|
842
|
+
config_hash: '0xe6d2e8fe49d722f55ced8a028c62ffbde16a05bc74d7d9703b675ecc8c820b4b',
|
|
843
|
+
definition_hash: '0xb5d81494f98df23cdff33909888080054f1068c11bbee5ec39aeb95edfa3b37c',
|
|
844
|
+
},
|
|
845
|
+
distributed_validators: [
|
|
846
|
+
{
|
|
847
|
+
distributed_public_key: '0x8368525a657df38fd3d774a08f1a54f008ae3340e8441a2bbb2d2051a9a8f46d4eeb8610bbc088e7402cba6b138c7b70',
|
|
848
|
+
public_shares: [
|
|
849
|
+
'0xae455c727456238fadd7b84ded0f0fb700d0e2fa028fff34e3fc73d0279ee9a5aa9843f8af00c9518ea781d8d823cc0d',
|
|
850
|
+
'0x91a7cfa9682464dff7324c0907fdff41df3f2643fd97d30559d82fbbfa354dae1e3f9176d8562b5ab47d3460240004cb',
|
|
851
|
+
'0xac8c0ffdb9ea7ce63bbed67122123c86ffa669a5027da5f96ab85b68c3a491253ebf0308cf4e237ea4eaf8543064c8a8',
|
|
852
|
+
'0x85385ef7cf1b1d9cd648ceb45e92516ef9612c9830b0abf808ea7996ad9369764bb9ac27c3cd730497e12e394ab48d16',
|
|
853
|
+
],
|
|
854
|
+
builder_registration: {
|
|
855
|
+
message: {
|
|
856
|
+
fee_recipient: '0xc6e76f72ea672fae05c357157cfc37720f0af26f',
|
|
857
|
+
gas_limit: 30000000,
|
|
858
|
+
timestamp: 1742213400,
|
|
859
|
+
pubkey: '0x8368525a657df38fd3d774a08f1a54f008ae3340e8441a2bbb2d2051a9a8f46d4eeb8610bbc088e7402cba6b138c7b70',
|
|
860
|
+
},
|
|
861
|
+
signature: '0xb73c4d55c17bdbbb53790fee3294ef2c69b2a6e4c700eb30603e437308005edacbe76591f917aa82cfcf60da2d669ccd101ae9b3dc4b1ae61ab7ad1794620adbdc0b4ea5f91fc5e790833537c610a57ccdc4c95ca53cb6dedec2be2ad8acf266',
|
|
862
|
+
},
|
|
863
|
+
partial_deposit_data: [
|
|
864
|
+
{
|
|
865
|
+
pubkey: '0x8368525a657df38fd3d774a08f1a54f008ae3340e8441a2bbb2d2051a9a8f46d4eeb8610bbc088e7402cba6b138c7b70',
|
|
866
|
+
withdrawal_credentials: '0x020000000000000000000000c6e76f72ea672fae05c357157cfc37720f0af26f',
|
|
867
|
+
amount: '32000000000',
|
|
868
|
+
signature: '0xa7c5c2417f5afd089b87df0eff10855b748d621749879b6087c8a1dbfcbb95aa79a2c8f4d637ecb283426b9c5af07c30080c19a245ea614ff3f609a92994e9a29f3c0f8c4bf1a4e7ef58615ff80586b40e36859c9fd935b68ae55670e29ea5d7',
|
|
869
|
+
},
|
|
870
|
+
],
|
|
871
|
+
},
|
|
872
|
+
],
|
|
873
|
+
signature_aggregate: '0x8b9f884ab3ab89d63f49437cae09e2b77757787f2c54bb52bc51df1d565bc6d63ef9fc4e0ea76bd72a58618651b827a611d8e96de238fad4616420b4cd393ad62428ac9db2e01a4e8dd8ae835845e7530f9e1b3b4ebf5ba2da3c77aec70d06b2',
|
|
874
|
+
lock_hash: '0xaf6b0d989fdd82f7f9683d62b9f797af129f9afae2a4b453a0bef1814b21ae5d',
|
|
875
|
+
node_signatures: [
|
|
876
|
+
'0xc059b3920fc107a909feb16217c7372911c5cb386954ed899b5d8e782d6d71e17a5dde1c2d4825b7c2b5edd63b4eb9c306afd4afd5dbce3f8db9c13d06d6cebf01',
|
|
877
|
+
'0x051a72e5f2a66a85aabd635a210350f82924350170981575f3cb67e7699791d7118ab7c284f10b52f3604a89aa0bc43ad2d2537a7b19b109610324926475d30900',
|
|
878
|
+
'0xa28a23de3703c3eeb9a091d4f47302a96079759baf1afca428cbd298b46c40fe103df0006dfd5a0ffd15ee7c5fa436d70d7a03d4537dd8292a6152734e5f689601',
|
|
879
|
+
'0x992ab5c73d30d10cc5c8f6d462ba387fd5a698e206b0dfdd0224d17117f85a2077fcaa62fd6d5170ff678249288fcd82877e2987ed5564df5dbd9d51370871c800',
|
|
880
|
+
],
|
|
881
|
+
};
|
|
@@ -10,10 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
var _a, _b;
|
|
11
11
|
import { ethers, JsonRpcProvider } from 'ethers';
|
|
12
12
|
import { Client, validateClusterLock } from '../src/index';
|
|
13
|
-
import { clusterConfigV1X7,
|
|
13
|
+
import { clusterConfigV1X7, clusterConfigV1X10, clusterLockV1X10, clusterLockV1X6, clusterLockV1X7, clusterLockV1X8, clusterLockWithCompoundingWithdrawals, clusterLockWithSafe, nullDepositAmountsClusterLockV1X8, } from './fixtures.js';
|
|
14
14
|
import { SDK_VERSION } from '../src/constants';
|
|
15
15
|
import { Base } from '../src/base';
|
|
16
|
-
import { validatePayload } from '../src/ajv';
|
|
17
16
|
import { HttpResponse, http } from 'msw';
|
|
18
17
|
import { setupServer } from 'msw/node';
|
|
19
18
|
import { hashTermsAndConditions } from '../src/verification/termsAndConditions';
|
|
@@ -40,31 +39,31 @@ describe('Cluster Client', () => {
|
|
|
40
39
|
clientInstance['request'] = jest
|
|
41
40
|
.fn()
|
|
42
41
|
.mockReturnValue(Promise.resolve({ config_hash: mockConfigHash }));
|
|
43
|
-
const configHash = yield clientInstance.createClusterDefinition(
|
|
42
|
+
const configHash = yield clientInstance.createClusterDefinition(clusterConfigV1X10);
|
|
44
43
|
expect(configHash).toEqual(mockConfigHash);
|
|
45
44
|
}));
|
|
46
45
|
test('acceptClusterDefinition should return cluster definition', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
46
|
clientInstance['request'] = jest
|
|
48
47
|
.fn()
|
|
49
|
-
.mockReturnValue(Promise.resolve(
|
|
48
|
+
.mockReturnValue(Promise.resolve(clusterLockV1X10.cluster_definition));
|
|
50
49
|
const clusterDefinition = yield clientInstance.acceptClusterDefinition({
|
|
51
|
-
enr:
|
|
52
|
-
version:
|
|
53
|
-
},
|
|
54
|
-
expect(clusterDefinition).toEqual(
|
|
50
|
+
enr: clusterLockV1X10.cluster_definition.operators[0].enr,
|
|
51
|
+
version: clusterLockV1X10.cluster_definition.version,
|
|
52
|
+
}, clusterLockV1X10.cluster_definition.config_hash);
|
|
53
|
+
expect(clusterDefinition).toEqual(clusterLockV1X10.cluster_definition);
|
|
55
54
|
}));
|
|
56
55
|
test('createClusterDefinition should throw an error on invalid operators', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
56
|
clientInstance['request'] = jest
|
|
58
57
|
.fn()
|
|
59
58
|
.mockReturnValue(Promise.resolve({ config_hash: mockConfigHash }));
|
|
60
59
|
try {
|
|
61
|
-
yield clientInstance.createClusterDefinition(Object.assign(Object.assign({},
|
|
60
|
+
yield clientInstance.createClusterDefinition(Object.assign(Object.assign({}, clusterConfigV1X10), { operators: [] }));
|
|
62
61
|
}
|
|
63
62
|
catch (error) {
|
|
64
|
-
expect(error.message).toEqual("
|
|
63
|
+
expect(error.message).toEqual('Validation failed: /operators must pass "validateUniqueAddresses" keyword validation, /operators must NOT have fewer than 4 items');
|
|
65
64
|
}
|
|
66
65
|
}));
|
|
67
|
-
// cause we default to
|
|
66
|
+
// cause we default to null
|
|
68
67
|
test('createClusterDefinition should accept a configuration without deposit_amounts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
68
|
clientInstance['request'] = jest
|
|
70
69
|
.fn()
|
|
@@ -80,32 +79,27 @@ describe('Cluster Client', () => {
|
|
|
80
79
|
yield clientInstance.createClusterDefinition(Object.assign(Object.assign({}, clusterConfigV1X7), { deposit_amounts: ['34000000'] }));
|
|
81
80
|
}
|
|
82
81
|
catch (error) {
|
|
83
|
-
expect(error.message).toEqual('
|
|
84
|
-
}
|
|
85
|
-
}));
|
|
86
|
-
test('validatePayload should throw an error on empty schema', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
-
try {
|
|
88
|
-
validatePayload(Object.assign(Object.assign({}, clusterConfigV1X8), { operators: [] }), '');
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
expect(error.message).toEqual('schema must be object or boolean');
|
|
82
|
+
expect(error.message).toEqual('Validation failed: /deposit_amounts/0 must be equal to one of the allowed values, /deposit_amounts must match "then" schema');
|
|
92
83
|
}
|
|
93
84
|
}));
|
|
94
85
|
test('getClusterdefinition should return cluster definition if config hash exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
-
var _a;
|
|
96
86
|
clientInstance['request'] = jest
|
|
97
87
|
.fn()
|
|
98
|
-
.mockReturnValue(Promise.resolve(
|
|
99
|
-
const clusterDefinition = yield clientInstance.getClusterDefinition(
|
|
100
|
-
expect(
|
|
101
|
-
expect(clusterDefinition.config_hash).toEqual(
|
|
88
|
+
.mockReturnValue(Promise.resolve(clusterLockV1X10.cluster_definition));
|
|
89
|
+
const clusterDefinition = yield clientInstance.getClusterDefinition(clusterLockV1X10.cluster_definition.config_hash);
|
|
90
|
+
expect(clusterDefinition.deposit_amounts).toBeDefined();
|
|
91
|
+
expect(clusterDefinition.config_hash).toEqual(clusterLockV1X10.cluster_definition.config_hash);
|
|
92
|
+
// Test for new fields
|
|
93
|
+
expect(clusterDefinition.compounding).toBeDefined();
|
|
94
|
+
expect(clusterDefinition.target_gas_limit).toBeDefined();
|
|
95
|
+
expect(clusterDefinition.consensus_protocol).toBeDefined();
|
|
102
96
|
}));
|
|
103
97
|
test('getClusterLock should return lockFile if exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
98
|
clientInstance['request'] = jest
|
|
105
99
|
.fn()
|
|
106
|
-
.mockReturnValue(Promise.resolve(
|
|
107
|
-
const clusterLock = yield clientInstance.getClusterLock(
|
|
108
|
-
expect(clusterLock.lock_hash).toEqual(
|
|
100
|
+
.mockReturnValue(Promise.resolve(clusterLockV1X10));
|
|
101
|
+
const clusterLock = yield clientInstance.getClusterLock(clusterLockV1X10.cluster_definition.config_hash);
|
|
102
|
+
expect(clusterLock.lock_hash).toEqual(clusterLockV1X10.lock_hash);
|
|
109
103
|
}));
|
|
110
104
|
test('request method should set user agent header', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
105
|
const server = setupServer(http.get('http://testexample.com/test', ({ request }) => {
|
|
@@ -145,7 +139,7 @@ describe('Cluster Client without a signer', () => {
|
|
|
145
139
|
});
|
|
146
140
|
test('createClusterDefinition should throw an error without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
141
|
try {
|
|
148
|
-
yield clientInstance.createClusterDefinition(
|
|
142
|
+
yield clientInstance.createClusterDefinition(clusterConfigV1X10);
|
|
149
143
|
}
|
|
150
144
|
catch (err) {
|
|
151
145
|
expect(err.message).toEqual('Signer is required in createClusterDefinition');
|
|
@@ -154,9 +148,9 @@ describe('Cluster Client without a signer', () => {
|
|
|
154
148
|
test('acceptClusterDefinition should throw an error without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
149
|
try {
|
|
156
150
|
yield clientInstance.acceptClusterDefinition({
|
|
157
|
-
enr:
|
|
158
|
-
version:
|
|
159
|
-
},
|
|
151
|
+
enr: clusterLockV1X10.cluster_definition.operators[0].enr,
|
|
152
|
+
version: clusterLockV1X10.cluster_definition.version,
|
|
153
|
+
}, clusterLockV1X10.cluster_definition.config_hash);
|
|
160
154
|
}
|
|
161
155
|
catch (err) {
|
|
162
156
|
expect(err.message).toEqual('Signer is required in acceptClusterDefinition');
|
|
@@ -165,16 +159,16 @@ describe('Cluster Client without a signer', () => {
|
|
|
165
159
|
test('getClusterdefinition should return cluster definition if config hash exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
160
|
clientInstance['request'] = jest
|
|
167
161
|
.fn()
|
|
168
|
-
.mockReturnValue(Promise.resolve(
|
|
169
|
-
const clusterDefinition = yield clientInstance.getClusterDefinition(
|
|
170
|
-
expect(clusterDefinition.config_hash).toEqual(
|
|
162
|
+
.mockReturnValue(Promise.resolve(clusterLockV1X10.cluster_definition));
|
|
163
|
+
const clusterDefinition = yield clientInstance.getClusterDefinition(clusterLockV1X10.cluster_definition.config_hash);
|
|
164
|
+
expect(clusterDefinition.config_hash).toEqual(clusterLockV1X10.cluster_definition.config_hash);
|
|
171
165
|
}));
|
|
172
166
|
test('getClusterLock should return lockFile if exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
167
|
clientInstance['request'] = jest
|
|
174
168
|
.fn()
|
|
175
|
-
.mockReturnValue(Promise.resolve(
|
|
176
|
-
const clusterLock = yield clientInstance.getClusterLock(
|
|
177
|
-
expect(clusterLock.lock_hash).toEqual(
|
|
169
|
+
.mockReturnValue(Promise.resolve(clusterLockV1X10));
|
|
170
|
+
const clusterLock = yield clientInstance.getClusterLock(clusterLockV1X10.cluster_definition.config_hash);
|
|
171
|
+
expect(clusterLock.lock_hash).toEqual(clusterLockV1X10.lock_hash);
|
|
178
172
|
}));
|
|
179
173
|
test.each([
|
|
180
174
|
{ version: 'v1.6.0', clusterLock: clusterLockV1X6 },
|
|
@@ -281,7 +275,7 @@ describe('createObolRewardsSplit', () => {
|
|
|
281
275
|
});
|
|
282
276
|
}
|
|
283
277
|
catch (error) {
|
|
284
|
-
expect(error.message).toEqual('
|
|
278
|
+
expect(error.message).toEqual('Validation failed: must pass "validateRewardsSplitRecipients" keyword validation');
|
|
285
279
|
}
|
|
286
280
|
}));
|
|
287
281
|
test('should throw an error if ObolRAFSplit is less than 1', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -294,7 +288,7 @@ describe('createObolRewardsSplit', () => {
|
|
|
294
288
|
});
|
|
295
289
|
}
|
|
296
290
|
catch (error) {
|
|
297
|
-
expect(error.message).toEqual("
|
|
291
|
+
expect(error.message).toEqual('Validation failed: must pass "validateRewardsSplitRecipients" keyword validation, /ObolRAFSplit must be >= 1');
|
|
298
292
|
}
|
|
299
293
|
}));
|
|
300
294
|
it('should return the correct withdrawal and fee recipient addresses', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -361,7 +355,7 @@ describe('createObolTotalSplit', () => {
|
|
|
361
355
|
});
|
|
362
356
|
}
|
|
363
357
|
catch (error) {
|
|
364
|
-
expect(error.message).toEqual('
|
|
358
|
+
expect(error.message).toEqual('Validation failed: must pass "validateTotalSplitRecipients" keyword validation');
|
|
365
359
|
}
|
|
366
360
|
}));
|
|
367
361
|
test('should throw an error if ObolRAFSplit is less than 0.1', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -372,13 +366,13 @@ describe('createObolTotalSplit', () => {
|
|
|
372
366
|
});
|
|
373
367
|
}
|
|
374
368
|
catch (error) {
|
|
375
|
-
expect(error.message).toEqual("
|
|
369
|
+
expect(error.message).toEqual('Validation failed: must pass "validateTotalSplitRecipients" keyword validation, /ObolRAFSplit must be >= 0.1');
|
|
376
370
|
}
|
|
377
371
|
}));
|
|
378
372
|
it('should return the correct withdrawal and fee recipient addresses and ObolRAFSplit', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
379
373
|
const result = yield clientInstance.createObolTotalSplit({
|
|
380
374
|
splitRecipients: mockSplitRecipients,
|
|
381
|
-
ObolRAFSplit: 0.
|
|
375
|
+
ObolRAFSplit: 0.1,
|
|
382
376
|
});
|
|
383
377
|
// 0xPredictedAddress and not 0xSplitterAddress since were mocking isContractAvailable response to be true
|
|
384
378
|
expect(result).toEqual({
|
package/dist/types/src/ajv.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
1
|
+
export declare const VALID_DEPOSIT_AMOUNTS: string[];
|
|
2
|
+
export declare const VALID_NON_COMPOUNDING_AMOUNTS: string[];
|
|
3
|
+
export declare function validatePayload<T>(data: unknown, schema: object): T;
|
|
@@ -69,7 +69,7 @@ export declare const signEnrPayload: (payload: {
|
|
|
69
69
|
enr: string;
|
|
70
70
|
}, chainId: number) => TypedMessage<typeof ENRTypedMessage>;
|
|
71
71
|
export declare const DKG_ALGORITHM = "default";
|
|
72
|
-
export declare const CONFIG_VERSION = "v1.
|
|
72
|
+
export declare const CONFIG_VERSION = "v1.10.0";
|
|
73
73
|
export declare const SDK_VERSION: string;
|
|
74
74
|
export declare const DOMAIN_APPLICATION_BUILDER = "00000001";
|
|
75
75
|
export declare const DOMAIN_DEPOSIT = "03000000";
|
|
@@ -5,6 +5,7 @@ export * from './types.js';
|
|
|
5
5
|
export * from './services.js';
|
|
6
6
|
export * from './verification/signature-validator.js';
|
|
7
7
|
export * from './verification/common.js';
|
|
8
|
+
export * from './constants.js';
|
|
8
9
|
export { Incentives } from './incentives.js';
|
|
9
10
|
/**
|
|
10
11
|
* Obol sdk Client can be used for creating, managing and activating distributed validators.
|
|
@@ -19,18 +19,16 @@ export declare const definitionSchema: {
|
|
|
19
19
|
operators: {
|
|
20
20
|
type: string;
|
|
21
21
|
minItems: number;
|
|
22
|
-
uniqueItems: boolean;
|
|
23
22
|
items: {
|
|
24
23
|
type: string;
|
|
25
24
|
properties: {
|
|
26
25
|
address: {
|
|
27
26
|
type: string;
|
|
28
|
-
minLength: number;
|
|
29
|
-
maxLength: number;
|
|
30
27
|
};
|
|
31
28
|
};
|
|
32
29
|
required: string[];
|
|
33
30
|
};
|
|
31
|
+
validateUniqueAddresses: boolean;
|
|
34
32
|
};
|
|
35
33
|
validators: {
|
|
36
34
|
type: string;
|
|
@@ -51,12 +49,39 @@ export declare const definitionSchema: {
|
|
|
51
49
|
};
|
|
52
50
|
};
|
|
53
51
|
deposit_amounts: {
|
|
54
|
-
type: string;
|
|
52
|
+
type: string[];
|
|
55
53
|
items: {
|
|
56
54
|
type: string;
|
|
57
55
|
pattern: string;
|
|
58
56
|
};
|
|
59
|
-
|
|
57
|
+
if: {
|
|
58
|
+
$data: string;
|
|
59
|
+
};
|
|
60
|
+
then: {
|
|
61
|
+
items: {
|
|
62
|
+
enum: string[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
else: {
|
|
66
|
+
items: {
|
|
67
|
+
enum: string[];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
default: null;
|
|
71
|
+
};
|
|
72
|
+
compounding: {
|
|
73
|
+
type: string;
|
|
74
|
+
default: boolean;
|
|
75
|
+
};
|
|
76
|
+
target_gas_limit: {
|
|
77
|
+
type: string;
|
|
78
|
+
minimum: number;
|
|
79
|
+
default: number;
|
|
80
|
+
};
|
|
81
|
+
consensus_protocol: {
|
|
82
|
+
type: string;
|
|
83
|
+
enum: string[];
|
|
84
|
+
default: string;
|
|
60
85
|
};
|
|
61
86
|
};
|
|
62
87
|
required: string[];
|
|
@@ -83,29 +108,35 @@ export declare const totalSplitterPayloadSchema: {
|
|
|
83
108
|
ObolRAFSplit: {
|
|
84
109
|
type: string;
|
|
85
110
|
minimum: number;
|
|
111
|
+
default: number;
|
|
86
112
|
};
|
|
87
113
|
distributorFee: {
|
|
88
114
|
type: string;
|
|
89
115
|
maximum: number;
|
|
90
116
|
multipleOf: number;
|
|
117
|
+
default: number;
|
|
91
118
|
};
|
|
92
119
|
controllerAddress: {
|
|
93
120
|
type: string;
|
|
94
121
|
pattern: string;
|
|
122
|
+
default: string;
|
|
95
123
|
};
|
|
96
|
-
validateSplitRecipients: boolean;
|
|
97
124
|
};
|
|
125
|
+
validateTotalSplitRecipients: boolean;
|
|
98
126
|
required: string[];
|
|
99
127
|
};
|
|
100
128
|
export declare const rewardsSplitterPayloadSchema: {
|
|
129
|
+
type: string;
|
|
101
130
|
properties: {
|
|
102
131
|
ObolRAFSplit: {
|
|
103
132
|
type: string;
|
|
104
133
|
minimum: number;
|
|
134
|
+
default: number;
|
|
105
135
|
};
|
|
106
136
|
recoveryAddress: {
|
|
107
137
|
type: string;
|
|
108
138
|
pattern: string;
|
|
139
|
+
default: string;
|
|
109
140
|
};
|
|
110
141
|
etherAmount: {
|
|
111
142
|
type: string;
|
|
@@ -134,13 +165,14 @@ export declare const rewardsSplitterPayloadSchema: {
|
|
|
134
165
|
type: string;
|
|
135
166
|
maximum: number;
|
|
136
167
|
multipleOf: number;
|
|
168
|
+
default: number;
|
|
137
169
|
};
|
|
138
170
|
controllerAddress: {
|
|
139
171
|
type: string;
|
|
140
172
|
pattern: string;
|
|
173
|
+
default: string;
|
|
141
174
|
};
|
|
142
|
-
validateSplitRecipients: boolean;
|
|
143
175
|
};
|
|
176
|
+
validateRewardsSplitRecipients: boolean;
|
|
144
177
|
required: string[];
|
|
145
|
-
type: string;
|
|
146
178
|
};
|
|
@@ -68,6 +68,12 @@ export type ClusterPayload = {
|
|
|
68
68
|
validators: ClusterValidator[];
|
|
69
69
|
/** The cluster partial deposits in gwei or 32000000000. */
|
|
70
70
|
deposit_amounts?: string[] | null;
|
|
71
|
+
/** A withdrawal mechanism with 0x02 withdrawal credentials. */
|
|
72
|
+
compounding?: boolean;
|
|
73
|
+
/** The target gas limit where default is 36M. */
|
|
74
|
+
target_gas_limit?: number;
|
|
75
|
+
/** The consensus protocol e.g qbft. */
|
|
76
|
+
consensus_protocol?: string;
|
|
71
77
|
};
|
|
72
78
|
/**
|
|
73
79
|
* Cluster definition data needed for dkg
|
|
@@ -95,7 +101,7 @@ export interface ClusterDefinition extends ClusterPayload {
|
|
|
95
101
|
definition_hash?: string;
|
|
96
102
|
/** The consensus protocol e.g qbft. */
|
|
97
103
|
consensus_protocol?: string;
|
|
98
|
-
/** The target gas limit where default is
|
|
104
|
+
/** The target gas limit where default is 36M. */
|
|
99
105
|
target_gas_limit?: number;
|
|
100
106
|
/** A withdrawal mechanism with 0x02 withdrawal credentials. */
|
|
101
107
|
compounding?: boolean;
|
|
@@ -219,7 +225,7 @@ export type ClaimableIncentives = {
|
|
|
219
225
|
operator_address: string;
|
|
220
226
|
/** The amount the recipient is entitled to. */
|
|
221
227
|
amount: string;
|
|
222
|
-
/** The recipient
|
|
228
|
+
/** The recipient's index in the Merkle tree. */
|
|
223
229
|
index: number;
|
|
224
230
|
/** The Merkle proof (an array of hashes) generated for the recipient. */
|
|
225
231
|
merkle_proof: string[];
|
|
@@ -99,17 +99,6 @@ export declare const clusterLockV1X7: {
|
|
|
99
99
|
lock_hash: string;
|
|
100
100
|
node_signatures: string[];
|
|
101
101
|
};
|
|
102
|
-
export declare const clusterConfigV1X8: {
|
|
103
|
-
name: string;
|
|
104
|
-
operators: {
|
|
105
|
-
address: string;
|
|
106
|
-
}[];
|
|
107
|
-
validators: {
|
|
108
|
-
fee_recipient_address: string;
|
|
109
|
-
withdrawal_address: string;
|
|
110
|
-
}[];
|
|
111
|
-
deposit_amounts: string[];
|
|
112
|
-
};
|
|
113
102
|
export declare const clusterLockV1X8: {
|
|
114
103
|
cluster_definition: {
|
|
115
104
|
name: string;
|
|
@@ -263,6 +252,30 @@ export declare const clusterLockWithSafe: {
|
|
|
263
252
|
lock_hash: string;
|
|
264
253
|
node_signatures: string[];
|
|
265
254
|
};
|
|
255
|
+
export declare const clusterConfigV1X10: {
|
|
256
|
+
name: string;
|
|
257
|
+
operators: {
|
|
258
|
+
address: string;
|
|
259
|
+
}[];
|
|
260
|
+
validators: {
|
|
261
|
+
fee_recipient_address: string;
|
|
262
|
+
withdrawal_address: string;
|
|
263
|
+
}[];
|
|
264
|
+
deposit_amounts: string[];
|
|
265
|
+
compounding: boolean;
|
|
266
|
+
target_gas_limit: number;
|
|
267
|
+
consensus_protocol: string;
|
|
268
|
+
};
|
|
269
|
+
export declare const soloClusterConfigV1X10: {
|
|
270
|
+
name: string;
|
|
271
|
+
operators: {
|
|
272
|
+
address: string;
|
|
273
|
+
}[];
|
|
274
|
+
validators: {
|
|
275
|
+
fee_recipient_address: string;
|
|
276
|
+
withdrawal_address: string;
|
|
277
|
+
}[];
|
|
278
|
+
};
|
|
266
279
|
export declare const clusterLockV1X10: {
|
|
267
280
|
cluster_definition: {
|
|
268
281
|
name: string;
|
|
@@ -371,3 +384,57 @@ export declare const clusterLockWithCompoundingWithdrawals: {
|
|
|
371
384
|
lock_hash: string;
|
|
372
385
|
node_signatures: string[];
|
|
373
386
|
};
|
|
387
|
+
export declare const clusterLockWithCompoundingWithdrawalss: {
|
|
388
|
+
cluster_definition: {
|
|
389
|
+
name: string;
|
|
390
|
+
creator: {
|
|
391
|
+
address: string;
|
|
392
|
+
config_signature: string;
|
|
393
|
+
};
|
|
394
|
+
operators: {
|
|
395
|
+
address: string;
|
|
396
|
+
enr: string;
|
|
397
|
+
config_signature: string;
|
|
398
|
+
enr_signature: string;
|
|
399
|
+
}[];
|
|
400
|
+
uuid: string;
|
|
401
|
+
version: string;
|
|
402
|
+
timestamp: string;
|
|
403
|
+
num_validators: number;
|
|
404
|
+
threshold: number;
|
|
405
|
+
validators: {
|
|
406
|
+
fee_recipient_address: string;
|
|
407
|
+
withdrawal_address: string;
|
|
408
|
+
}[];
|
|
409
|
+
dkg_algorithm: string;
|
|
410
|
+
fork_version: string;
|
|
411
|
+
deposit_amounts: string[];
|
|
412
|
+
consensus_protocol: string;
|
|
413
|
+
target_gas_limit: number;
|
|
414
|
+
compounding: boolean;
|
|
415
|
+
config_hash: string;
|
|
416
|
+
definition_hash: string;
|
|
417
|
+
};
|
|
418
|
+
distributed_validators: {
|
|
419
|
+
distributed_public_key: string;
|
|
420
|
+
public_shares: string[];
|
|
421
|
+
builder_registration: {
|
|
422
|
+
message: {
|
|
423
|
+
fee_recipient: string;
|
|
424
|
+
gas_limit: number;
|
|
425
|
+
timestamp: number;
|
|
426
|
+
pubkey: string;
|
|
427
|
+
};
|
|
428
|
+
signature: string;
|
|
429
|
+
};
|
|
430
|
+
partial_deposit_data: {
|
|
431
|
+
pubkey: string;
|
|
432
|
+
withdrawal_credentials: string;
|
|
433
|
+
amount: string;
|
|
434
|
+
signature: string;
|
|
435
|
+
}[];
|
|
436
|
+
}[];
|
|
437
|
+
signature_aggregate: string;
|
|
438
|
+
lock_hash: string;
|
|
439
|
+
node_signatures: string[];
|
|
440
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obolnetwork/obol-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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"
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"@safe-global/safe-core-sdk-types": "5.1.0",
|
|
50
50
|
"@types/pdf-parse": "^1.1.4",
|
|
51
51
|
"ajv": "^8.12.0",
|
|
52
|
+
"ajv-formats": "^3.0.1",
|
|
53
|
+
"ajv-keywords": "^5.1.0",
|
|
52
54
|
"cross-fetch": "^3.1.5",
|
|
53
55
|
"dotenv": "^16.4.7",
|
|
54
56
|
"elliptic": "^6.5.4",
|