@obolnetwork/obol-sdk 1.0.9 → 1.0.12
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 +2 -1
- package/dist/cjs/src/ajv.js +17 -0
- package/dist/cjs/src/base.js +39 -0
- package/dist/cjs/src/constants.js +86 -0
- package/dist/cjs/src/errors.js +11 -0
- package/dist/cjs/src/hash.js +172 -0
- package/dist/cjs/src/index.js +158 -0
- package/dist/cjs/src/schema.js +72 -0
- package/dist/cjs/src/services.js +32 -0
- package/dist/cjs/src/types.js +18 -0
- package/dist/cjs/src/utils.js +11 -0
- package/dist/cjs/src/verify.js +326 -0
- package/dist/cjs/test/fixtures.js +101 -0
- package/dist/cjs/test/methods.test.js +128 -0
- package/dist/esm/src/ajv.js +10 -0
- package/dist/esm/src/base.js +35 -0
- package/dist/esm/src/constants.js +79 -0
- package/dist/esm/src/errors.js +7 -0
- package/dist/esm/src/hash.js +165 -0
- package/dist/esm/src/index.js +140 -0
- package/dist/esm/src/schema.js +69 -0
- package/dist/esm/src/services.js +28 -0
- package/dist/esm/src/types.js +15 -0
- package/dist/esm/src/utils.js +6 -0
- package/dist/esm/src/verify.js +295 -0
- package/dist/esm/test/fixtures.js +98 -0
- package/dist/esm/test/methods.test.js +126 -0
- package/dist/{ajv.d.ts → types/src/ajv.d.ts} +2 -3
- package/dist/{base.d.ts → types/src/base.d.ts} +13 -14
- package/dist/types/src/constants.d.ts +79 -0
- package/dist/{errors.d.ts → types/src/errors.d.ts} +4 -5
- package/dist/{hash.d.ts → types/src/hash.d.ts} +56 -64
- package/dist/{index.d.ts → types/src/index.d.ts} +64 -60
- package/dist/{schema.d.ts → types/src/schema.d.ts} +57 -58
- package/dist/types/src/services.d.ts +11 -0
- package/dist/{types.d.ts → types/src/types.d.ts} +153 -154
- package/dist/types/src/utils.d.ts +2 -0
- package/dist/types/src/verify.d.ts +4 -0
- package/dist/{fixtures.d.ts → types/test/fixtures.d.ts} +61 -62
- package/dist/types/test/methods.test.d.ts +1 -0
- package/package.json +55 -20
- package/src/ajv.ts +11 -0
- package/src/base.ts +44 -0
- package/src/constants.ts +118 -0
- package/src/errors.ts +11 -0
- package/src/hash.ts +250 -0
- package/src/index.ts +160 -0
- package/src/schema.ts +70 -0
- package/src/services.ts +20 -0
- package/src/types.ts +211 -0
- package/src/utils.ts +7 -0
- package/src/verify.ts +479 -0
- package/dist/ajv.d.ts.map +0 -1
- package/dist/base.d.ts.map +0 -1
- package/dist/cluster.test.d.ts +0 -2
- package/dist/cluster.test.d.ts.map +0 -1
- package/dist/constants.d.ts +0 -30
- package/dist/constants.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/fixtures.d.ts.map +0 -1
- package/dist/hash.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.es.js +0 -15582
- package/dist/index.js +0 -15586
- package/dist/schema.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -1,154 +1,153 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Permitted ChainID's
|
|
3
|
-
*/
|
|
4
|
-
export declare enum FORK_MAPPING {
|
|
5
|
-
/** Mainnet. */
|
|
6
|
-
"0x00000000" = 1,
|
|
7
|
-
/** Goerli/Prater. */
|
|
8
|
-
"0x00001020" = 5,
|
|
9
|
-
/** Gnosis Chain. */
|
|
10
|
-
"0x00000064" = 100,
|
|
11
|
-
/** Holesky. */
|
|
12
|
-
"0x01017000" = 17000
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export
|
|
18
|
-
/** The operator address. */
|
|
19
|
-
address: string;
|
|
20
|
-
/** The operator ethereum node record. */
|
|
21
|
-
enr?: string;
|
|
22
|
-
/** The cluster fork_version. */
|
|
23
|
-
fork_version?: string;
|
|
24
|
-
/** The cluster version. */
|
|
25
|
-
version?: string;
|
|
26
|
-
/** The operator enr signature. */
|
|
27
|
-
enr_signature?: string;
|
|
28
|
-
/** The operator configuration signature. */
|
|
29
|
-
config_signature?: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* A partial view of `ClusterOperator` with `enr` and `version` as required properties.
|
|
33
|
-
*/
|
|
34
|
-
export
|
|
35
|
-
/**
|
|
36
|
-
* Cluster
|
|
37
|
-
*/
|
|
38
|
-
export
|
|
39
|
-
/** The creator address. */
|
|
40
|
-
address: string;
|
|
41
|
-
/** The cluster configuration signature. */
|
|
42
|
-
config_signature?: string;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
export
|
|
48
|
-
/** The validator fee recipient address. */
|
|
49
|
-
fee_recipient_address: string;
|
|
50
|
-
/** The validator reward address. */
|
|
51
|
-
withdrawal_address: string;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Cluster
|
|
55
|
-
*/
|
|
56
|
-
export
|
|
57
|
-
/** The cluster name. */
|
|
58
|
-
name: string;
|
|
59
|
-
/** The cluster nodes operators addresses. */
|
|
60
|
-
operators: ClusterOperator[];
|
|
61
|
-
/** The clusters validators information. */
|
|
62
|
-
validators: ClusterValidator[];
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Cluster
|
|
66
|
-
*/
|
|
67
|
-
export interface ClusterDefintion extends ClusterPayload {
|
|
68
|
-
/** The creator of the cluster. */
|
|
69
|
-
creator: ClusterCreator;
|
|
70
|
-
/** The cluster configuration version. */
|
|
71
|
-
version: string;
|
|
72
|
-
/** The cluster dkg algorithm. */
|
|
73
|
-
dkg_algorithm: string;
|
|
74
|
-
/** The cluster fork version. */
|
|
75
|
-
fork_version: string;
|
|
76
|
-
/** The cluster uuid. */
|
|
77
|
-
uuid: string;
|
|
78
|
-
/** The cluster creation timestamp. */
|
|
79
|
-
timestamp: string;
|
|
80
|
-
/** The cluster configuration hash. */
|
|
81
|
-
config_hash: string;
|
|
82
|
-
/** The distributed validator threshold. */
|
|
83
|
-
threshold: number;
|
|
84
|
-
/** The number of distributed validators in the cluster. */
|
|
85
|
-
num_validators: number;
|
|
86
|
-
/** The hash of the cluster definition. */
|
|
87
|
-
definition_hash?: string;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Unsigned DV Builder Registration Message
|
|
91
|
-
*/
|
|
92
|
-
export
|
|
93
|
-
/** The DV fee recipient. */
|
|
94
|
-
fee_recipient: string;
|
|
95
|
-
/** Default is 30000000. */
|
|
96
|
-
gas_limit: number;
|
|
97
|
-
/** Timestamp when generating cluster lock file. */
|
|
98
|
-
timestamp: number;
|
|
99
|
-
/** The public key of the DV. */
|
|
100
|
-
pubkey: string;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Pre-generated Signed Validator Builder Registration
|
|
104
|
-
*/
|
|
105
|
-
export
|
|
106
|
-
/** Builder registration message. */
|
|
107
|
-
message: BuilderRegistrationMessage;
|
|
108
|
-
/** BLS signature of the builder registration message. */
|
|
109
|
-
signature: string;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
*/
|
|
114
|
-
export
|
|
115
|
-
/** The public key of the distributed validator. */
|
|
116
|
-
pubkey: string;
|
|
117
|
-
/** The 0x01 withdrawal address of the DV. */
|
|
118
|
-
withdrawal_credentials: string;
|
|
119
|
-
/** 32 ethers. */
|
|
120
|
-
amount: string;
|
|
121
|
-
/** A checksum for DepositData fields . */
|
|
122
|
-
deposit_data_root: string;
|
|
123
|
-
/** BLS signature of the deposit message. */
|
|
124
|
-
signature: string;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
*
|
|
128
|
-
*/
|
|
129
|
-
export
|
|
130
|
-
/** The public key of the distributed validator. */
|
|
131
|
-
distributed_public_key: string;
|
|
132
|
-
/** The public key of the node distributed validator share. */
|
|
133
|
-
public_shares: string[];
|
|
134
|
-
/** The required deposit data for activating the DV. */
|
|
135
|
-
deposit_data: Partial<DepositData>;
|
|
136
|
-
/** pre-generated signed validator builder registration to be sent to builder network. */
|
|
137
|
-
builder_registration: BuilderRegistration;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Cluster
|
|
141
|
-
*/
|
|
142
|
-
export
|
|
143
|
-
/** The cluster definition. */
|
|
144
|
-
cluster_definition: ClusterDefintion;
|
|
145
|
-
/** The cluster distributed validators. */
|
|
146
|
-
distributed_validators: DistributedValidator[];
|
|
147
|
-
/** The cluster bls signature aggregate. */
|
|
148
|
-
signature_aggregate: string;
|
|
149
|
-
/** The hash of the cluster lock. */
|
|
150
|
-
lock_hash: string;
|
|
151
|
-
/** Node Signature for the lock hash by the node secp256k1 key. */
|
|
152
|
-
node_signatures: string[];
|
|
153
|
-
}
|
|
154
|
-
//# sourceMappingURL=types.d.ts.map
|
|
1
|
+
/**
|
|
2
|
+
* Permitted ChainID's
|
|
3
|
+
*/
|
|
4
|
+
export declare enum FORK_MAPPING {
|
|
5
|
+
/** Mainnet. */
|
|
6
|
+
"0x00000000" = 1,
|
|
7
|
+
/** Goerli/Prater. */
|
|
8
|
+
"0x00001020" = 5,
|
|
9
|
+
/** Gnosis Chain. */
|
|
10
|
+
"0x00000064" = 100,
|
|
11
|
+
/** Holesky. */
|
|
12
|
+
"0x01017000" = 17000
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Node operator data
|
|
16
|
+
*/
|
|
17
|
+
export type ClusterOperator = {
|
|
18
|
+
/** The operator address. */
|
|
19
|
+
address: string;
|
|
20
|
+
/** The operator ethereum node record. */
|
|
21
|
+
enr?: string;
|
|
22
|
+
/** The cluster fork_version. */
|
|
23
|
+
fork_version?: string;
|
|
24
|
+
/** The cluster version. */
|
|
25
|
+
version?: string;
|
|
26
|
+
/** The operator enr signature. */
|
|
27
|
+
enr_signature?: string;
|
|
28
|
+
/** The operator configuration signature. */
|
|
29
|
+
config_signature?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A partial view of `ClusterOperator` with `enr` and `version` as required properties.
|
|
33
|
+
*/
|
|
34
|
+
export type OperatorPayload = Partial<ClusterOperator> & Required<Pick<ClusterOperator, 'enr' | 'version'>>;
|
|
35
|
+
/**
|
|
36
|
+
* Cluster creator data
|
|
37
|
+
*/
|
|
38
|
+
export type ClusterCreator = {
|
|
39
|
+
/** The creator address. */
|
|
40
|
+
address: string;
|
|
41
|
+
/** The cluster configuration signature. */
|
|
42
|
+
config_signature?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Validator withdrawal configuration
|
|
46
|
+
*/
|
|
47
|
+
export type ClusterValidator = {
|
|
48
|
+
/** The validator fee recipient address. */
|
|
49
|
+
fee_recipient_address: string;
|
|
50
|
+
/** The validator reward address. */
|
|
51
|
+
withdrawal_address: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Cluster configuration
|
|
55
|
+
*/
|
|
56
|
+
export type ClusterPayload = {
|
|
57
|
+
/** The cluster name. */
|
|
58
|
+
name: string;
|
|
59
|
+
/** The cluster nodes operators addresses. */
|
|
60
|
+
operators: ClusterOperator[];
|
|
61
|
+
/** The clusters validators information. */
|
|
62
|
+
validators: ClusterValidator[];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Cluster definition data needed for dkg
|
|
66
|
+
*/
|
|
67
|
+
export interface ClusterDefintion extends ClusterPayload {
|
|
68
|
+
/** The creator of the cluster. */
|
|
69
|
+
creator: ClusterCreator;
|
|
70
|
+
/** The cluster configuration version. */
|
|
71
|
+
version: string;
|
|
72
|
+
/** The cluster dkg algorithm. */
|
|
73
|
+
dkg_algorithm: string;
|
|
74
|
+
/** The cluster fork version. */
|
|
75
|
+
fork_version: string;
|
|
76
|
+
/** The cluster uuid. */
|
|
77
|
+
uuid: string;
|
|
78
|
+
/** The cluster creation timestamp. */
|
|
79
|
+
timestamp: string;
|
|
80
|
+
/** The cluster configuration hash. */
|
|
81
|
+
config_hash: string;
|
|
82
|
+
/** The distributed validator threshold. */
|
|
83
|
+
threshold: number;
|
|
84
|
+
/** The number of distributed validators in the cluster. */
|
|
85
|
+
num_validators: number;
|
|
86
|
+
/** The hash of the cluster definition. */
|
|
87
|
+
definition_hash?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Unsigned DV Builder Registration Message
|
|
91
|
+
*/
|
|
92
|
+
export type BuilderRegistrationMessage = {
|
|
93
|
+
/** The DV fee recipient. */
|
|
94
|
+
fee_recipient: string;
|
|
95
|
+
/** Default is 30000000. */
|
|
96
|
+
gas_limit: number;
|
|
97
|
+
/** Timestamp when generating cluster lock file. */
|
|
98
|
+
timestamp: number;
|
|
99
|
+
/** The public key of the DV. */
|
|
100
|
+
pubkey: string;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Pre-generated Signed Validator Builder Registration
|
|
104
|
+
*/
|
|
105
|
+
export type BuilderRegistration = {
|
|
106
|
+
/** Builder registration message. */
|
|
107
|
+
message: BuilderRegistrationMessage;
|
|
108
|
+
/** BLS signature of the builder registration message. */
|
|
109
|
+
signature: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Required deposit data for validator activation
|
|
113
|
+
*/
|
|
114
|
+
export type DepositData = {
|
|
115
|
+
/** The public key of the distributed validator. */
|
|
116
|
+
pubkey: string;
|
|
117
|
+
/** The 0x01 withdrawal address of the DV. */
|
|
118
|
+
withdrawal_credentials: string;
|
|
119
|
+
/** 32 ethers. */
|
|
120
|
+
amount: string;
|
|
121
|
+
/** A checksum for DepositData fields . */
|
|
122
|
+
deposit_data_root: string;
|
|
123
|
+
/** BLS signature of the deposit message. */
|
|
124
|
+
signature: string;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Required deposit data for validator activation
|
|
128
|
+
*/
|
|
129
|
+
export type DistributedValidator = {
|
|
130
|
+
/** The public key of the distributed validator. */
|
|
131
|
+
distributed_public_key: string;
|
|
132
|
+
/** The public key of the node distributed validator share. */
|
|
133
|
+
public_shares: string[];
|
|
134
|
+
/** The required deposit data for activating the DV. */
|
|
135
|
+
deposit_data: Partial<DepositData>;
|
|
136
|
+
/** pre-generated signed validator builder registration to be sent to builder network. */
|
|
137
|
+
builder_registration: BuilderRegistration;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Cluster Details after DKG is complete
|
|
141
|
+
*/
|
|
142
|
+
export type ClusterLock = {
|
|
143
|
+
/** The cluster definition. */
|
|
144
|
+
cluster_definition: ClusterDefintion;
|
|
145
|
+
/** The cluster distributed validators. */
|
|
146
|
+
distributed_validators: DistributedValidator[];
|
|
147
|
+
/** The cluster bls signature aggregate. */
|
|
148
|
+
signature_aggregate: string;
|
|
149
|
+
/** The hash of the cluster lock. */
|
|
150
|
+
lock_hash: string;
|
|
151
|
+
/** Node Signature for the lock hash by the node secp256k1 key. */
|
|
152
|
+
node_signatures: string[];
|
|
153
|
+
};
|
|
@@ -1,62 +1,61 @@
|
|
|
1
|
-
export declare const clusterLockV1X7: {
|
|
2
|
-
cluster_definition: {
|
|
3
|
-
name: string;
|
|
4
|
-
creator: {
|
|
5
|
-
address: string;
|
|
6
|
-
config_signature: string;
|
|
7
|
-
};
|
|
8
|
-
operators: {
|
|
9
|
-
address: string;
|
|
10
|
-
enr: string;
|
|
11
|
-
config_signature: string;
|
|
12
|
-
enr_signature: string;
|
|
13
|
-
}[];
|
|
14
|
-
uuid: string;
|
|
15
|
-
version: string;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
num_validators: number;
|
|
18
|
-
threshold: number;
|
|
19
|
-
validators: {
|
|
20
|
-
fee_recipient_address: string;
|
|
21
|
-
withdrawal_address: string;
|
|
22
|
-
}[];
|
|
23
|
-
dkg_algorithm: string;
|
|
24
|
-
fork_version: string;
|
|
25
|
-
config_hash: string;
|
|
26
|
-
definition_hash: string;
|
|
27
|
-
};
|
|
28
|
-
distributed_validators: {
|
|
29
|
-
distributed_public_key: string;
|
|
30
|
-
public_shares: string[];
|
|
31
|
-
deposit_data: {
|
|
32
|
-
pubkey: string;
|
|
33
|
-
withdrawal_credentials: string;
|
|
34
|
-
amount: string;
|
|
35
|
-
signature: string;
|
|
36
|
-
deposit_data_root: string;
|
|
37
|
-
};
|
|
38
|
-
builder_registration: {
|
|
39
|
-
message: {
|
|
40
|
-
fee_recipient: string;
|
|
41
|
-
gas_limit: number;
|
|
42
|
-
timestamp: number;
|
|
43
|
-
pubkey: string;
|
|
44
|
-
};
|
|
45
|
-
signature: string;
|
|
46
|
-
};
|
|
47
|
-
}[];
|
|
48
|
-
signature_aggregate: string;
|
|
49
|
-
lock_hash: string;
|
|
50
|
-
node_signatures: string[];
|
|
51
|
-
};
|
|
52
|
-
export declare const clusterConfig: {
|
|
53
|
-
name: string;
|
|
54
|
-
operators: {
|
|
55
|
-
address: string;
|
|
56
|
-
}[];
|
|
57
|
-
validators: {
|
|
58
|
-
fee_recipient_address: string;
|
|
59
|
-
withdrawal_address: string;
|
|
60
|
-
}[];
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=fixtures.d.ts.map
|
|
1
|
+
export declare const clusterLockV1X7: {
|
|
2
|
+
cluster_definition: {
|
|
3
|
+
name: string;
|
|
4
|
+
creator: {
|
|
5
|
+
address: string;
|
|
6
|
+
config_signature: string;
|
|
7
|
+
};
|
|
8
|
+
operators: {
|
|
9
|
+
address: string;
|
|
10
|
+
enr: string;
|
|
11
|
+
config_signature: string;
|
|
12
|
+
enr_signature: string;
|
|
13
|
+
}[];
|
|
14
|
+
uuid: string;
|
|
15
|
+
version: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
num_validators: number;
|
|
18
|
+
threshold: number;
|
|
19
|
+
validators: {
|
|
20
|
+
fee_recipient_address: string;
|
|
21
|
+
withdrawal_address: string;
|
|
22
|
+
}[];
|
|
23
|
+
dkg_algorithm: string;
|
|
24
|
+
fork_version: string;
|
|
25
|
+
config_hash: string;
|
|
26
|
+
definition_hash: string;
|
|
27
|
+
};
|
|
28
|
+
distributed_validators: {
|
|
29
|
+
distributed_public_key: string;
|
|
30
|
+
public_shares: string[];
|
|
31
|
+
deposit_data: {
|
|
32
|
+
pubkey: string;
|
|
33
|
+
withdrawal_credentials: string;
|
|
34
|
+
amount: string;
|
|
35
|
+
signature: string;
|
|
36
|
+
deposit_data_root: string;
|
|
37
|
+
};
|
|
38
|
+
builder_registration: {
|
|
39
|
+
message: {
|
|
40
|
+
fee_recipient: string;
|
|
41
|
+
gas_limit: number;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
pubkey: string;
|
|
44
|
+
};
|
|
45
|
+
signature: string;
|
|
46
|
+
};
|
|
47
|
+
}[];
|
|
48
|
+
signature_aggregate: string;
|
|
49
|
+
lock_hash: string;
|
|
50
|
+
node_signatures: string[];
|
|
51
|
+
};
|
|
52
|
+
export declare const clusterConfig: {
|
|
53
|
+
name: string;
|
|
54
|
+
operators: {
|
|
55
|
+
address: string;
|
|
56
|
+
}[];
|
|
57
|
+
validators: {
|
|
58
|
+
fee_recipient_address: string;
|
|
59
|
+
withdrawal_address: string;
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,59 +1,94 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obolnetwork/obol-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "A package for creating Distributed Validators using the Obol API.",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/obolnetwork/obol-packages/issues"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://docs.obol.tech/",
|
|
8
9
|
"keywords": [
|
|
9
10
|
"Obol",
|
|
10
11
|
"Distributed Validators",
|
|
11
12
|
"Ethereum"
|
|
12
13
|
],
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
14
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
15
|
+
"compile": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json",
|
|
16
|
+
"build:clean": "rm -rf ./dist",
|
|
17
|
+
"build": "npm-run-all build:clean compile",
|
|
18
|
+
"test": "jest ./test/methods.test.ts",
|
|
20
19
|
"generate-typedoc": "typedoc",
|
|
20
|
+
"ds:release": "npm publish --tag latest",
|
|
21
21
|
"ds:release:major": "npm version $(semver $npm_package_version -i major) && npm publish --tag latest",
|
|
22
22
|
"ds:release:minor": "npm version $(semver $npm_package_version -i minor) && npm publish --tag latest",
|
|
23
23
|
"ds:release:patch": "npm version $(semver $npm_package_version -i patch) && npm publish --tag latest"
|
|
24
24
|
},
|
|
25
|
+
"main": "./dist/cjs/src/index.js",
|
|
26
|
+
"module": "./dist/esm/src/index.js",
|
|
27
|
+
"typings": "./dist/types/src/index.d.ts",
|
|
25
28
|
"author": "Obol Labs (https://obol.tech)",
|
|
26
29
|
"repository": {
|
|
27
30
|
"type": "git",
|
|
28
31
|
"url": "git+https://github.com/obolnetwork/obol-packages.git"
|
|
29
32
|
},
|
|
30
33
|
"license": "ISC",
|
|
31
|
-
"bugs": {
|
|
32
|
-
"url": "https://github.com/obolnetwork/obol-packages/issues"
|
|
33
|
-
},
|
|
34
|
-
"homepage": "https://docs.obol.tech/",
|
|
35
34
|
"publishConfig": {
|
|
36
35
|
"registry": "https://registry.npmjs.org/",
|
|
37
36
|
"access": "public"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@chainsafe/
|
|
39
|
+
"@chainsafe/bls": "6.0.3",
|
|
40
|
+
"@chainsafe/blst": "^0.2.9",
|
|
41
|
+
"@chainsafe/discv5": "^0.5.1",
|
|
42
|
+
"@chainsafe/ssz": "^0.14.0",
|
|
43
|
+
"@metamask/eth-sig-util": "^7.0.1",
|
|
41
44
|
"ajv": "^8.12.0",
|
|
42
45
|
"cross-fetch": "^3.1.5",
|
|
46
|
+
"elliptic": "^6.5.4",
|
|
43
47
|
"ethers": "^6.4.0",
|
|
48
|
+
"nock": "^13.5.3",
|
|
44
49
|
"uuid": "^9.0.0"
|
|
45
50
|
},
|
|
46
51
|
"devDependencies": {
|
|
52
|
+
"@types/elliptic": "^6.4.18",
|
|
47
53
|
"@types/jest": "^28.1.8",
|
|
48
54
|
"@types/node": "^20.2.5",
|
|
49
55
|
"@types/uuid": "^9.0.1",
|
|
50
|
-
"
|
|
56
|
+
"eslint": "^8.6.0",
|
|
51
57
|
"jest": "^28.1.3",
|
|
52
|
-
"
|
|
58
|
+
"msw": "^2.2.1",
|
|
59
|
+
"npm-run-all": "^4.1.5",
|
|
53
60
|
"ts-jest": "^28.0.8",
|
|
54
|
-
"tsconfig": "*",
|
|
55
61
|
"tsup": "^6.7.0",
|
|
56
|
-
"typedoc": "^0.
|
|
57
|
-
"
|
|
62
|
+
"typedoc": "^0.25.7",
|
|
63
|
+
"typedoc-plugin-markdown": "^4.0.0-next.50",
|
|
64
|
+
"typescript": "^5.3.3"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">= 16"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"package.json",
|
|
71
|
+
"README.md",
|
|
72
|
+
"dist",
|
|
73
|
+
"src"
|
|
74
|
+
],
|
|
75
|
+
"jest": {
|
|
76
|
+
"transform": {
|
|
77
|
+
"\\.[jt]sx?$": "ts-jest"
|
|
78
|
+
},
|
|
79
|
+
"globals": {
|
|
80
|
+
"ts-jest": {
|
|
81
|
+
"useESM": true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"moduleNameMapper": {
|
|
85
|
+
"^bn.js$": "<rootDir>/node_modules/bn.js",
|
|
86
|
+
"^asn1.js$": "<rootDir>/node_modules/asn1.js",
|
|
87
|
+
"^hash.js$": "<rootDir>/node_modules/hash.js",
|
|
88
|
+
"(.+)\\.js": "$1"
|
|
89
|
+
},
|
|
90
|
+
"extensionsToTreatAsEsm": [
|
|
91
|
+
".ts"
|
|
92
|
+
]
|
|
58
93
|
}
|
|
59
94
|
}
|
package/src/ajv.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Ajv, { ErrorObject } from 'ajv';
|
|
2
|
+
|
|
3
|
+
export function validatePayload(data: any, schema: any): ErrorObject[] | undefined | null | boolean {
|
|
4
|
+
const ajv = new Ajv();
|
|
5
|
+
const validate = ajv.compile(schema);
|
|
6
|
+
const isValid = validate(data);
|
|
7
|
+
if (!isValid) {
|
|
8
|
+
throw new Error(`Schema compilation errors', ${validate.errors && validate.errors[0].message}`);
|
|
9
|
+
}
|
|
10
|
+
return isValid;
|
|
11
|
+
}
|
package/src/base.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/resources/base.ts
|
|
2
|
+
import { DEFAULT_BASE_URL, DEFAULT_CHAIN_ID, SDK_VERSION } from './constants.js';
|
|
3
|
+
import { FORK_MAPPING } from './types.js';
|
|
4
|
+
|
|
5
|
+
type Config = {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
chainId?: FORK_MAPPING;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export abstract class Base {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
chainId: number;
|
|
13
|
+
fork_version: string;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
constructor({ baseUrl = DEFAULT_BASE_URL, chainId = DEFAULT_CHAIN_ID }: Config) {
|
|
18
|
+
this.baseUrl = baseUrl;
|
|
19
|
+
this.chainId = chainId;
|
|
20
|
+
this.fork_version = FORK_MAPPING[this.chainId]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected async request<T>(endpoint: string, options?: RequestInit): Promise<T> {
|
|
24
|
+
const url = `${this.baseUrl}${endpoint}`
|
|
25
|
+
const config = {
|
|
26
|
+
...options,
|
|
27
|
+
headers: {
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
'User-Agent': `Obol-SDK/${SDK_VERSION}`,
|
|
30
|
+
...options?.headers
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(url, config);
|
|
36
|
+
if (response.ok) {
|
|
37
|
+
return (await response.json())
|
|
38
|
+
}
|
|
39
|
+
throw new Error(response.statusText);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
throw e
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|