@obolnetwork/obol-sdk 1.0.9 → 1.0.11
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 +54 -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,64 +1,56 @@
|
|
|
1
|
-
import { ContainerType, ByteVectorType, UintNumberType, ListCompositeType, ByteListType } from '@chainsafe/ssz';
|
|
2
|
-
import { ValueOfFields } from '@chainsafe/ssz/lib/view/container';
|
|
3
|
-
import { ClusterDefintion } from './types';
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export
|
|
57
|
-
/**
|
|
58
|
-
* Returns the containerized cluster definition
|
|
59
|
-
* @param cluster ClusterDefinition to calculate the type from
|
|
60
|
-
* @returns SSZ Containerized type of cluster input
|
|
61
|
-
*/
|
|
62
|
-
export declare const clusterDefinitionContainerTypeV1X7: (configOnly: boolean) => DefinitionContainerTypeV1X7;
|
|
63
|
-
export {};
|
|
64
|
-
//# sourceMappingURL=hash.d.ts.map
|
|
1
|
+
import { ContainerType, ByteVectorType, UintNumberType, ListCompositeType, ByteListType } from '@chainsafe/ssz';
|
|
2
|
+
import { ValueOfFields } from '@chainsafe/ssz/lib/view/container.js';
|
|
3
|
+
import { ClusterDefintion, ClusterLock } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* @param cluster The cluster configuration or the cluster definition
|
|
6
|
+
* @param configOnly a boolean to indicate config hash or definition hash
|
|
7
|
+
* @returns The config hash or the definition hash in of the corresponding cluster
|
|
8
|
+
*/
|
|
9
|
+
export declare const clusterConfigOrDefinitionHash: (cluster: ClusterDefintion, configOnly: boolean) => string;
|
|
10
|
+
export declare const hashClusterDefinition: (cluster: ClusterDefintion, configOnly: boolean) => ValueOfFields<DefinitionFields>;
|
|
11
|
+
declare const operatorAddressWrapperType: ContainerType<{
|
|
12
|
+
address: ByteVectorType;
|
|
13
|
+
}>;
|
|
14
|
+
declare const creatorAddressWrapperType: ContainerType<{
|
|
15
|
+
address: ByteVectorType;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const operatorContainerType: ContainerType<{
|
|
18
|
+
address: ByteVectorType;
|
|
19
|
+
enr: ByteListType;
|
|
20
|
+
config_signature: ByteVectorType;
|
|
21
|
+
enr_signature: ByteVectorType;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const creatorContainerType: ContainerType<{
|
|
24
|
+
address: ByteVectorType;
|
|
25
|
+
config_signature: ByteVectorType;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const validatorsContainerType: ContainerType<{
|
|
28
|
+
fee_recipient_address: ByteVectorType;
|
|
29
|
+
withdrawal_address: ByteVectorType;
|
|
30
|
+
}>;
|
|
31
|
+
type DefinitionFields = {
|
|
32
|
+
uuid: ByteListType;
|
|
33
|
+
name: ByteListType;
|
|
34
|
+
version: ByteListType;
|
|
35
|
+
timestamp: ByteListType;
|
|
36
|
+
num_validators: UintNumberType;
|
|
37
|
+
threshold: UintNumberType;
|
|
38
|
+
dkg_algorithm: ByteListType;
|
|
39
|
+
fork_version: ByteVectorType;
|
|
40
|
+
operators: ListCompositeType<typeof operatorContainerType | typeof operatorAddressWrapperType>;
|
|
41
|
+
creator: typeof creatorContainerType | typeof creatorAddressWrapperType;
|
|
42
|
+
validators: ListCompositeType<typeof validatorsContainerType>;
|
|
43
|
+
config_hash?: ByteVectorType;
|
|
44
|
+
};
|
|
45
|
+
export type DefinitionContainerType = ContainerType<DefinitionFields>;
|
|
46
|
+
/**
|
|
47
|
+
* @param configOnly a boolean to indicate config hash or definition hash
|
|
48
|
+
* @returns SSZ Containerized type of cluster definition
|
|
49
|
+
*/
|
|
50
|
+
export declare const clusterDefinitionContainerType: (configOnly: boolean) => DefinitionContainerType;
|
|
51
|
+
/**
|
|
52
|
+
* @param cluster The published cluster lock
|
|
53
|
+
* @returns The lock hash in of the corresponding cluster
|
|
54
|
+
*/
|
|
55
|
+
export declare const clusterLockHash: (cluster: ClusterLock) => string;
|
|
56
|
+
export {};
|
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
import { Signer } from
|
|
2
|
-
import { Base } from './base';
|
|
3
|
-
import { ClusterDefintion, ClusterLock, ClusterPayload, OperatorPayload } from './types';
|
|
4
|
-
export * from "./types";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @param
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import { Base } from './base.js';
|
|
3
|
+
import { ClusterDefintion, ClusterLock, ClusterPayload, OperatorPayload } from './types.js';
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./services.js";
|
|
6
|
+
/**
|
|
7
|
+
* Obol sdk Client can be used for creating, managing and activating distributed validators.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Client extends Base {
|
|
10
|
+
private signer;
|
|
11
|
+
/**
|
|
12
|
+
* @param config - Client configurations
|
|
13
|
+
* @param config.baseUrl - obol-api url
|
|
14
|
+
* @param config.chainId - Blockchain network ID
|
|
15
|
+
* @param signer - ethersJS Signer
|
|
16
|
+
* @returns Obol-SDK Client instance
|
|
17
|
+
*
|
|
18
|
+
* An example of how to instantiate obol-sdk Client:
|
|
19
|
+
* [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L29)
|
|
20
|
+
*/
|
|
21
|
+
constructor(config: {
|
|
22
|
+
baseUrl?: string | undefined;
|
|
23
|
+
chainId?: number | undefined;
|
|
24
|
+
}, signer?: Signer);
|
|
25
|
+
/**
|
|
26
|
+
* Creates a cluster definition which contains cluster configuration.
|
|
27
|
+
* @param {ClusterPayload} newCluster - The new unique cluster.
|
|
28
|
+
* @returns {Promise<string>} config_hash.
|
|
29
|
+
* @throws On duplicate entries, missing or wrong cluster keys.
|
|
30
|
+
*
|
|
31
|
+
* An example of how to use createClusterDefinition:
|
|
32
|
+
* [createObolCluster](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
33
|
+
*/
|
|
34
|
+
createClusterDefinition(newCluster: ClusterPayload): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Approves joining a cluster with specific configuration.
|
|
37
|
+
* @param {OperatorPayload} operatorPayload - The operator data including signatures.
|
|
38
|
+
* @param {string} configHash - The config hash of the cluster which the operator confirms joining to.
|
|
39
|
+
* @returns {Promise<ClusterDefintion>} The cluster definition.
|
|
40
|
+
* @throws On unauthorized, duplicate entries, missing keys, not found cluster or invalid data.
|
|
41
|
+
*
|
|
42
|
+
* An example of how to use acceptClusterDefinition:
|
|
43
|
+
* [acceptClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
44
|
+
*/
|
|
45
|
+
acceptClusterDefinition(operatorPayload: OperatorPayload, configHash: string): Promise<ClusterDefintion>;
|
|
46
|
+
/**
|
|
47
|
+
* @param configHash - The configuration hash returned in createClusterDefinition
|
|
48
|
+
* @returns {Promise<ClusterDefintion>} The cluster definition for config hash
|
|
49
|
+
* @throws On not found config hash.
|
|
50
|
+
*
|
|
51
|
+
* An example of how to use getClusterDefinition:
|
|
52
|
+
* [getObolClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
53
|
+
*/
|
|
54
|
+
getClusterDefinition(configHash: string): Promise<ClusterDefintion>;
|
|
55
|
+
/**
|
|
56
|
+
* @param configHash - The configuration hash in cluster-definition
|
|
57
|
+
* @returns {Promise<ClusterLock>} The matched cluster details (lock) from DB
|
|
58
|
+
* @throws On not found cluster definition or lock.
|
|
59
|
+
*
|
|
60
|
+
* An example of how to use getClusterLock:
|
|
61
|
+
* [getObolClusterLock](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
62
|
+
*/
|
|
63
|
+
getClusterLock(configHash: string): Promise<ClusterLock>;
|
|
64
|
+
}
|
|
@@ -1,58 +1,57 @@
|
|
|
1
|
-
export declare const operatorPayloadSchema: {
|
|
2
|
-
type: string;
|
|
3
|
-
properties: {
|
|
4
|
-
version: {
|
|
5
|
-
type: string;
|
|
6
|
-
};
|
|
7
|
-
enr: {
|
|
8
|
-
type: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
required: string[];
|
|
12
|
-
};
|
|
13
|
-
export declare const definitionSchema: {
|
|
14
|
-
type: string;
|
|
15
|
-
properties: {
|
|
16
|
-
name: {
|
|
17
|
-
type: string;
|
|
18
|
-
};
|
|
19
|
-
operators: {
|
|
20
|
-
type: string;
|
|
21
|
-
minItems: number;
|
|
22
|
-
uniqueItems: boolean;
|
|
23
|
-
items: {
|
|
24
|
-
type: string;
|
|
25
|
-
properties: {
|
|
26
|
-
address: {
|
|
27
|
-
type: string;
|
|
28
|
-
minLength: number;
|
|
29
|
-
maxLength: number;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
required: string[];
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
validators: {
|
|
36
|
-
type: string;
|
|
37
|
-
minItems: number;
|
|
38
|
-
items: {
|
|
39
|
-
type: string;
|
|
40
|
-
properties: {
|
|
41
|
-
fee_recipient_address: {
|
|
42
|
-
type: string;
|
|
43
|
-
minLength: number;
|
|
44
|
-
maxLength: number;
|
|
45
|
-
};
|
|
46
|
-
withdrawal_address: {
|
|
47
|
-
type: string;
|
|
48
|
-
minLength: number;
|
|
49
|
-
maxLength: number;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
required: string[];
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
required: string[];
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
1
|
+
export declare const operatorPayloadSchema: {
|
|
2
|
+
type: string;
|
|
3
|
+
properties: {
|
|
4
|
+
version: {
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
enr: {
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
required: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare const definitionSchema: {
|
|
14
|
+
type: string;
|
|
15
|
+
properties: {
|
|
16
|
+
name: {
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
operators: {
|
|
20
|
+
type: string;
|
|
21
|
+
minItems: number;
|
|
22
|
+
uniqueItems: boolean;
|
|
23
|
+
items: {
|
|
24
|
+
type: string;
|
|
25
|
+
properties: {
|
|
26
|
+
address: {
|
|
27
|
+
type: string;
|
|
28
|
+
minLength: number;
|
|
29
|
+
maxLength: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
validators: {
|
|
36
|
+
type: string;
|
|
37
|
+
minItems: number;
|
|
38
|
+
items: {
|
|
39
|
+
type: string;
|
|
40
|
+
properties: {
|
|
41
|
+
fee_recipient_address: {
|
|
42
|
+
type: string;
|
|
43
|
+
minLength: number;
|
|
44
|
+
maxLength: number;
|
|
45
|
+
};
|
|
46
|
+
withdrawal_address: {
|
|
47
|
+
type: string;
|
|
48
|
+
minLength: number;
|
|
49
|
+
maxLength: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
required: string[];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
required: string[];
|
|
57
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClusterLock } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Verifies Cluster Lock's validity.
|
|
4
|
+
* @param lock - cluster lock
|
|
5
|
+
* @returns {Promise<{ result: boolean }> } boolean result to indicate if lock is valid
|
|
6
|
+
* @throws on missing keys or values.
|
|
7
|
+
*
|
|
8
|
+
* An example of how to use validateClusterLock:
|
|
9
|
+
* [validateClusterLock](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
10
|
+
*/
|
|
11
|
+
export declare const validateClusterLock: (lock: ClusterLock) => Promise<boolean>;
|