@obolnetwork/obol-sdk 1.0.15 → 1.0.17
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 +6 -3
- package/dist/cjs/package.json +11 -6
- package/dist/cjs/src/ajv.js +27 -0
- package/dist/cjs/src/constants.js +8 -4
- package/dist/cjs/src/index.js +21 -18
- package/dist/cjs/src/schema.js +8 -0
- package/dist/cjs/src/services.js +1 -1
- package/dist/cjs/src/utils.js +3 -3
- package/dist/cjs/src/verification/common.js +19 -7
- package/dist/cjs/src/verification/termsAndConditions.js +1 -1
- package/dist/cjs/src/verification/v1.6.0.js +1 -1
- package/dist/cjs/src/verification/v1.7.0.js +3 -3
- package/dist/cjs/src/verification/v1.8.0.js +3 -3
- package/dist/cjs/test/fixtures.js +71 -82
- package/dist/cjs/test/methods.test.js +54 -27
- package/dist/esm/package.json +11 -6
- package/dist/esm/src/ajv.js +27 -0
- package/dist/esm/src/base.js +1 -1
- package/dist/esm/src/constants.js +7 -3
- package/dist/esm/src/index.js +22 -19
- package/dist/esm/src/schema.js +8 -0
- package/dist/esm/src/services.js +1 -1
- package/dist/esm/src/utils.js +3 -3
- package/dist/esm/src/verification/common.js +27 -15
- package/dist/esm/src/verification/sszTypes.js +1 -1
- package/dist/esm/src/verification/termsAndConditions.js +1 -1
- package/dist/esm/src/verification/v1.6.0.js +5 -5
- package/dist/esm/src/verification/v1.7.0.js +8 -8
- package/dist/esm/src/verification/v1.8.0.js +8 -8
- package/dist/esm/test/fixtures.js +71 -82
- package/dist/esm/test/methods.test.js +55 -28
- package/dist/types/src/constants.d.ts +3 -1
- package/dist/types/src/index.d.ts +11 -9
- package/dist/types/src/schema.d.ts +8 -0
- package/dist/types/src/services.d.ts +1 -1
- package/dist/types/src/types.d.ts +18 -18
- package/package.json +12 -7
- package/src/ajv.ts +38 -7
- package/src/base.ts +22 -18
- package/src/constants.ts +42 -36
- package/src/errors.ts +4 -4
- package/src/index.ts +96 -84
- package/src/schema.ts +10 -2
- package/src/services.ts +7 -7
- package/src/types.ts +65 -65
- package/src/utils.ts +17 -17
- package/src/verification/common.ts +374 -333
- package/src/verification/sszTypes.ts +60 -51
- package/src/verification/termsAndConditions.ts +16 -14
- package/src/verification/v1.6.0.ts +214 -184
- package/src/verification/v1.7.0.ts +268 -233
- package/src/verification/v1.8.0.ts +266 -225
package/src/types.ts
CHANGED
|
@@ -18,192 +18,192 @@ export enum FORK_MAPPING {
|
|
|
18
18
|
/**
|
|
19
19
|
* Node operator data
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export type ClusterOperator = {
|
|
22
22
|
/** The operator address. */
|
|
23
|
-
address: string
|
|
23
|
+
address: string;
|
|
24
24
|
|
|
25
25
|
/** The operator ethereum node record. */
|
|
26
|
-
enr?: string
|
|
26
|
+
enr?: string;
|
|
27
27
|
|
|
28
28
|
/** The cluster fork_version. */
|
|
29
|
-
fork_version?: string
|
|
29
|
+
fork_version?: string;
|
|
30
30
|
|
|
31
31
|
/** The cluster version. */
|
|
32
|
-
version?: string
|
|
32
|
+
version?: string;
|
|
33
33
|
|
|
34
34
|
/** The operator enr signature. */
|
|
35
|
-
enr_signature?: string
|
|
35
|
+
enr_signature?: string;
|
|
36
36
|
|
|
37
37
|
/** The operator configuration signature. */
|
|
38
|
-
config_signature?: string
|
|
39
|
-
}
|
|
38
|
+
config_signature?: string;
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* A partial view of `ClusterOperator` with `enr` and `version` as required properties.
|
|
43
43
|
*/
|
|
44
44
|
export type OperatorPayload = Partial<ClusterOperator> &
|
|
45
|
-
Required<Pick<ClusterOperator, 'enr' | 'version'
|
|
45
|
+
Required<Pick<ClusterOperator, 'enr' | 'version'>>;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Cluster creator data
|
|
49
49
|
*/
|
|
50
|
-
export
|
|
50
|
+
export type ClusterCreator = {
|
|
51
51
|
/** The creator address. */
|
|
52
|
-
address: string
|
|
52
|
+
address: string;
|
|
53
53
|
/** The cluster configuration signature. */
|
|
54
|
-
config_signature?: string
|
|
55
|
-
}
|
|
54
|
+
config_signature?: string;
|
|
55
|
+
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Validator withdrawal configuration
|
|
59
59
|
*/
|
|
60
|
-
export
|
|
60
|
+
export type ClusterValidator = {
|
|
61
61
|
/** The validator fee recipient address. */
|
|
62
|
-
fee_recipient_address: string
|
|
62
|
+
fee_recipient_address: string;
|
|
63
63
|
|
|
64
64
|
/** The validator reward address. */
|
|
65
|
-
withdrawal_address: string
|
|
66
|
-
}
|
|
65
|
+
withdrawal_address: string;
|
|
66
|
+
};
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Cluster configuration
|
|
70
70
|
*/
|
|
71
|
-
export
|
|
71
|
+
export type ClusterPayload = {
|
|
72
72
|
/** The cluster name. */
|
|
73
|
-
name: string
|
|
73
|
+
name: string;
|
|
74
74
|
|
|
75
75
|
/** The cluster nodes operators addresses. */
|
|
76
|
-
operators: ClusterOperator[]
|
|
76
|
+
operators: ClusterOperator[];
|
|
77
77
|
|
|
78
78
|
/** The cluster validators information. */
|
|
79
|
-
validators: ClusterValidator[]
|
|
79
|
+
validators: ClusterValidator[];
|
|
80
80
|
|
|
81
81
|
/** The cluster partial deposits in gwei or 32000000000. */
|
|
82
|
-
deposit_amounts?: string[]
|
|
83
|
-
}
|
|
82
|
+
deposit_amounts?: string[];
|
|
83
|
+
};
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* Cluster definition data needed for dkg
|
|
87
87
|
*/
|
|
88
88
|
export interface ClusterDefinition extends ClusterPayload {
|
|
89
89
|
/** The creator of the cluster. */
|
|
90
|
-
creator: ClusterCreator
|
|
90
|
+
creator: ClusterCreator;
|
|
91
91
|
|
|
92
92
|
/** The cluster configuration version. */
|
|
93
|
-
version: string
|
|
93
|
+
version: string;
|
|
94
94
|
|
|
95
95
|
/** The cluster dkg algorithm. */
|
|
96
|
-
dkg_algorithm: string
|
|
96
|
+
dkg_algorithm: string;
|
|
97
97
|
|
|
98
98
|
/** The cluster fork version. */
|
|
99
|
-
fork_version: string
|
|
99
|
+
fork_version: string;
|
|
100
100
|
|
|
101
101
|
/** The cluster uuid. */
|
|
102
|
-
uuid: string
|
|
102
|
+
uuid: string;
|
|
103
103
|
|
|
104
104
|
/** The cluster creation timestamp. */
|
|
105
|
-
timestamp: string
|
|
105
|
+
timestamp: string;
|
|
106
106
|
|
|
107
107
|
/** The cluster configuration hash. */
|
|
108
|
-
config_hash: string
|
|
108
|
+
config_hash: string;
|
|
109
109
|
|
|
110
110
|
/** The distributed validator threshold. */
|
|
111
|
-
threshold: number
|
|
111
|
+
threshold: number;
|
|
112
112
|
|
|
113
113
|
/** The number of distributed validators in the cluster. */
|
|
114
|
-
num_validators: number
|
|
114
|
+
num_validators: number;
|
|
115
115
|
|
|
116
116
|
/** The cluster partial deposits in gwei or 32000000000. */
|
|
117
|
-
deposit_amounts?: string[]
|
|
117
|
+
deposit_amounts?: string[];
|
|
118
118
|
|
|
119
119
|
/** The hash of the cluster definition. */
|
|
120
|
-
definition_hash?: string
|
|
120
|
+
definition_hash?: string;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Unsigned DV Builder Registration Message
|
|
125
125
|
*/
|
|
126
|
-
export
|
|
126
|
+
export type BuilderRegistrationMessage = {
|
|
127
127
|
/** The DV fee recipient. */
|
|
128
|
-
fee_recipient: string
|
|
128
|
+
fee_recipient: string;
|
|
129
129
|
|
|
130
130
|
/** Default is 30000000. */
|
|
131
|
-
gas_limit: number
|
|
131
|
+
gas_limit: number;
|
|
132
132
|
|
|
133
133
|
/** Timestamp when generating cluster lock file. */
|
|
134
|
-
timestamp: number
|
|
134
|
+
timestamp: number;
|
|
135
135
|
|
|
136
136
|
/** The public key of the DV. */
|
|
137
|
-
pubkey: string
|
|
138
|
-
}
|
|
137
|
+
pubkey: string;
|
|
138
|
+
};
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* Pre-generated Signed Validator Builder Registration
|
|
142
142
|
*/
|
|
143
|
-
export
|
|
143
|
+
export type BuilderRegistration = {
|
|
144
144
|
/** Builder registration message. */
|
|
145
|
-
message: BuilderRegistrationMessage
|
|
145
|
+
message: BuilderRegistrationMessage;
|
|
146
146
|
|
|
147
147
|
/** BLS signature of the builder registration message. */
|
|
148
|
-
signature: string
|
|
149
|
-
}
|
|
148
|
+
signature: string;
|
|
149
|
+
};
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Required deposit data for validator activation
|
|
153
153
|
*/
|
|
154
|
-
export
|
|
154
|
+
export type DepositData = {
|
|
155
155
|
/** The public key of the distributed validator. */
|
|
156
|
-
pubkey: string
|
|
156
|
+
pubkey: string;
|
|
157
157
|
|
|
158
158
|
/** The 0x01 withdrawal address of the DV. */
|
|
159
|
-
withdrawal_credentials: string
|
|
159
|
+
withdrawal_credentials: string;
|
|
160
160
|
|
|
161
161
|
/** 32 ethers. */
|
|
162
|
-
amount: string
|
|
162
|
+
amount: string;
|
|
163
163
|
|
|
164
164
|
/** A checksum for DepositData fields . */
|
|
165
|
-
deposit_data_root: string
|
|
165
|
+
deposit_data_root: string;
|
|
166
166
|
|
|
167
167
|
/** BLS signature of the deposit message. */
|
|
168
|
-
signature: string
|
|
169
|
-
}
|
|
168
|
+
signature: string;
|
|
169
|
+
};
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Required deposit data for validator activation
|
|
173
173
|
*/
|
|
174
|
-
export
|
|
174
|
+
export type DistributedValidator = {
|
|
175
175
|
/** The public key of the distributed validator. */
|
|
176
|
-
distributed_public_key: string
|
|
176
|
+
distributed_public_key: string;
|
|
177
177
|
|
|
178
178
|
/** The public key of the node distributed validator share. */
|
|
179
|
-
public_shares: string[]
|
|
179
|
+
public_shares: string[];
|
|
180
180
|
|
|
181
181
|
/** The deposit data for activating the DV. */
|
|
182
|
-
deposit_data?: Partial<DepositData
|
|
182
|
+
deposit_data?: Partial<DepositData>;
|
|
183
183
|
|
|
184
184
|
/** The deposit data with partial amounts or full amount for activating the DV. */
|
|
185
|
-
partial_deposit_data?: Array<Partial<DepositData
|
|
185
|
+
partial_deposit_data?: Array<Partial<DepositData>>;
|
|
186
186
|
|
|
187
187
|
/** pre-generated signed validator builder registration to be sent to builder network. */
|
|
188
|
-
builder_registration?: BuilderRegistration
|
|
189
|
-
}
|
|
188
|
+
builder_registration?: BuilderRegistration;
|
|
189
|
+
};
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
192
|
* Cluster Details after DKG is complete
|
|
193
193
|
*/
|
|
194
|
-
export
|
|
194
|
+
export type ClusterLock = {
|
|
195
195
|
/** The cluster definition. */
|
|
196
|
-
cluster_definition: ClusterDefinition
|
|
196
|
+
cluster_definition: ClusterDefinition;
|
|
197
197
|
|
|
198
198
|
/** The cluster distributed validators. */
|
|
199
|
-
distributed_validators: DistributedValidator[]
|
|
199
|
+
distributed_validators: DistributedValidator[];
|
|
200
200
|
|
|
201
201
|
/** The cluster bls signature aggregate. */
|
|
202
|
-
signature_aggregate: string
|
|
202
|
+
signature_aggregate: string;
|
|
203
203
|
|
|
204
204
|
/** The hash of the cluster lock. */
|
|
205
|
-
lock_hash: string
|
|
205
|
+
lock_hash: string;
|
|
206
206
|
|
|
207
207
|
/** Node Signature for the lock hash by the node secp256k1 key. */
|
|
208
|
-
node_signatures?: string[]
|
|
209
|
-
}
|
|
208
|
+
node_signatures?: string[];
|
|
209
|
+
};
|
package/src/utils.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DefinitionFlow } from './constants'
|
|
2
|
-
import { type ClusterDefinition } from './types'
|
|
1
|
+
import { DefinitionFlow } from './constants';
|
|
2
|
+
import { type ClusterDefinition } from './types';
|
|
3
3
|
|
|
4
4
|
export const hexWithout0x = (hex: string): string => {
|
|
5
|
-
return hex.slice(2, hex.length)
|
|
6
|
-
}
|
|
5
|
+
return hex.slice(2, hex.length);
|
|
6
|
+
};
|
|
7
7
|
|
|
8
8
|
export const strToUint8Array = (str: string): Uint8Array => {
|
|
9
|
-
return new TextEncoder().encode(str)
|
|
10
|
-
}
|
|
9
|
+
return new TextEncoder().encode(str);
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
export const definitionFlow = (
|
|
13
13
|
clusterDefinition: ClusterDefinition,
|
|
@@ -15,42 +15,42 @@ export const definitionFlow = (
|
|
|
15
15
|
if (
|
|
16
16
|
clusterDefinition.creator.address &&
|
|
17
17
|
clusterDefinition.creator.config_signature &&
|
|
18
|
-
clusterDefinition.operators.every(
|
|
18
|
+
clusterDefinition.operators.every(operator => {
|
|
19
19
|
return (
|
|
20
20
|
operator.address &&
|
|
21
21
|
operator.config_signature &&
|
|
22
22
|
operator.enr &&
|
|
23
23
|
operator.enr_signature
|
|
24
|
-
)
|
|
24
|
+
);
|
|
25
25
|
})
|
|
26
26
|
) {
|
|
27
|
-
return DefinitionFlow.Group
|
|
27
|
+
return DefinitionFlow.Group;
|
|
28
28
|
} else if (
|
|
29
29
|
clusterDefinition.creator.address &&
|
|
30
30
|
clusterDefinition.creator.config_signature &&
|
|
31
|
-
clusterDefinition.operators.every(
|
|
31
|
+
clusterDefinition.operators.every(operator => {
|
|
32
32
|
return (
|
|
33
33
|
!operator.address &&
|
|
34
34
|
!operator.config_signature &&
|
|
35
35
|
operator.enr &&
|
|
36
36
|
!operator.enr_signature
|
|
37
|
-
)
|
|
37
|
+
);
|
|
38
38
|
})
|
|
39
39
|
) {
|
|
40
|
-
return DefinitionFlow.Solo
|
|
40
|
+
return DefinitionFlow.Solo;
|
|
41
41
|
} else if (
|
|
42
42
|
!clusterDefinition.creator.address &&
|
|
43
43
|
!clusterDefinition.creator.config_signature &&
|
|
44
|
-
clusterDefinition.operators.every(
|
|
44
|
+
clusterDefinition.operators.every(operator => {
|
|
45
45
|
return (
|
|
46
46
|
!operator.address &&
|
|
47
47
|
!operator.config_signature &&
|
|
48
48
|
operator.enr &&
|
|
49
49
|
!operator.enr_signature
|
|
50
|
-
)
|
|
50
|
+
);
|
|
51
51
|
})
|
|
52
52
|
) {
|
|
53
|
-
return DefinitionFlow.Charon
|
|
53
|
+
return DefinitionFlow.Charon;
|
|
54
54
|
}
|
|
55
|
-
return null
|
|
56
|
-
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|