@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.
Files changed (66) hide show
  1. package/README.md +2 -1
  2. package/dist/cjs/src/ajv.js +17 -0
  3. package/dist/cjs/src/base.js +39 -0
  4. package/dist/cjs/src/constants.js +86 -0
  5. package/dist/cjs/src/errors.js +11 -0
  6. package/dist/cjs/src/hash.js +172 -0
  7. package/dist/cjs/src/index.js +158 -0
  8. package/dist/cjs/src/schema.js +72 -0
  9. package/dist/cjs/src/services.js +32 -0
  10. package/dist/cjs/src/types.js +18 -0
  11. package/dist/cjs/src/utils.js +11 -0
  12. package/dist/cjs/src/verify.js +326 -0
  13. package/dist/cjs/test/fixtures.js +101 -0
  14. package/dist/cjs/test/methods.test.js +128 -0
  15. package/dist/esm/src/ajv.js +10 -0
  16. package/dist/esm/src/base.js +35 -0
  17. package/dist/esm/src/constants.js +79 -0
  18. package/dist/esm/src/errors.js +7 -0
  19. package/dist/esm/src/hash.js +165 -0
  20. package/dist/esm/src/index.js +140 -0
  21. package/dist/esm/src/schema.js +69 -0
  22. package/dist/esm/src/services.js +28 -0
  23. package/dist/esm/src/types.js +15 -0
  24. package/dist/esm/src/utils.js +6 -0
  25. package/dist/esm/src/verify.js +295 -0
  26. package/dist/esm/test/fixtures.js +98 -0
  27. package/dist/esm/test/methods.test.js +126 -0
  28. package/dist/{ajv.d.ts → types/src/ajv.d.ts} +2 -3
  29. package/dist/{base.d.ts → types/src/base.d.ts} +13 -14
  30. package/dist/types/src/constants.d.ts +79 -0
  31. package/dist/{errors.d.ts → types/src/errors.d.ts} +4 -5
  32. package/dist/{hash.d.ts → types/src/hash.d.ts} +56 -64
  33. package/dist/{index.d.ts → types/src/index.d.ts} +64 -60
  34. package/dist/{schema.d.ts → types/src/schema.d.ts} +57 -58
  35. package/dist/types/src/services.d.ts +11 -0
  36. package/dist/{types.d.ts → types/src/types.d.ts} +153 -154
  37. package/dist/types/src/utils.d.ts +2 -0
  38. package/dist/types/src/verify.d.ts +4 -0
  39. package/dist/{fixtures.d.ts → types/test/fixtures.d.ts} +61 -62
  40. package/dist/types/test/methods.test.d.ts +1 -0
  41. package/package.json +54 -20
  42. package/src/ajv.ts +11 -0
  43. package/src/base.ts +44 -0
  44. package/src/constants.ts +118 -0
  45. package/src/errors.ts +11 -0
  46. package/src/hash.ts +250 -0
  47. package/src/index.ts +160 -0
  48. package/src/schema.ts +70 -0
  49. package/src/services.ts +20 -0
  50. package/src/types.ts +211 -0
  51. package/src/utils.ts +7 -0
  52. package/src/verify.ts +479 -0
  53. package/dist/ajv.d.ts.map +0 -1
  54. package/dist/base.d.ts.map +0 -1
  55. package/dist/cluster.test.d.ts +0 -2
  56. package/dist/cluster.test.d.ts.map +0 -1
  57. package/dist/constants.d.ts +0 -30
  58. package/dist/constants.d.ts.map +0 -1
  59. package/dist/errors.d.ts.map +0 -1
  60. package/dist/fixtures.d.ts.map +0 -1
  61. package/dist/hash.d.ts.map +0 -1
  62. package/dist/index.d.ts.map +0 -1
  63. package/dist/index.es.js +0 -15582
  64. package/dist/index.js +0 -15586
  65. package/dist/schema.d.ts.map +0 -1
  66. 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
- * Returns the SSZ cluster config hash or the definition hash of the given cluster definition object
6
- * @param cluster The cluster whose config hash or definition hash needs to be calculated
7
- * @param configOnly A flag that indicates which hash to evaluate
8
- * @returns The config hash or he definition hash in of the corresponding cluster definition
9
- */
10
- export declare const clusterConfigOrDefinitionHash: (cluster: ClusterDefintion, configOnly: boolean) => string;
11
- export declare const hashClusterDefinitionV1X7: (cluster: ClusterDefintion, configOnly: boolean) => ValueOfFields<DefinitionFieldsV1X7>;
12
- /**
13
- * Converts a string to a Uint8Array
14
- * @param str The string to convert
15
- * @returns The converted Uint8Array
16
- */
17
- export declare const strToUint8Array: (str: string) => Uint8Array;
18
- /**
19
- * operatorContainerType is an SSZ Composite Container type for Operator.
20
- * Note that the type has fixed size for address as it is an ETH1 address (20 bytes).
21
- */
22
- declare const operatorAddressWrapperType: ContainerType<{
23
- address: ByteVectorType;
24
- }>;
25
- declare const creatorAddressWrapperType: ContainerType<{
26
- address: ByteVectorType;
27
- }>;
28
- export declare const operatorContainerType: ContainerType<{
29
- address: ByteVectorType;
30
- enr: ByteListType;
31
- config_signature: ByteVectorType;
32
- enr_signature: ByteVectorType;
33
- }>;
34
- export declare const creatorContainerType: ContainerType<{
35
- address: ByteVectorType;
36
- config_signature: ByteVectorType;
37
- }>;
38
- export declare const validatorsContainerType: ContainerType<{
39
- fee_recipient_address: ByteVectorType;
40
- withdrawal_address: ByteVectorType;
41
- }>;
42
- declare type DefinitionFieldsV1X7 = {
43
- uuid: ByteListType;
44
- name: ByteListType;
45
- version: ByteListType;
46
- timestamp: ByteListType;
47
- num_validators: UintNumberType;
48
- threshold: UintNumberType;
49
- dkg_algorithm: ByteListType;
50
- fork_version: ByteVectorType;
51
- operators: ListCompositeType<typeof operatorContainerType | typeof operatorAddressWrapperType>;
52
- creator: typeof creatorContainerType | typeof creatorAddressWrapperType;
53
- validators: ListCompositeType<typeof validatorsContainerType>;
54
- config_hash?: ByteVectorType;
55
- };
56
- export declare type DefinitionContainerTypeV1X7 = ContainerType<DefinitionFieldsV1X7>;
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 'ethers';
2
- import { Base } from './base';
3
- import { ClusterDefintion, ClusterLock, ClusterPayload, OperatorPayload } from './types';
4
- export * from "./types";
5
- /**
6
- * Obol sdk Client can be used for creating, managing and activating distributed validators.
7
- */
8
- export declare class Client extends Base {
9
- private signer;
10
- /**
11
- * @param config
12
- * @param signer ethersJS Signer
13
- * @returns Obol-SDK Client instance
14
- *
15
- * An example of how to instantiate obol-sdk Client:
16
- * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L29)
17
- */
18
- constructor(config: {
19
- baseUrl?: string | undefined;
20
- chainId?: number | undefined;
21
- }, signer?: Signer);
22
- /**
23
- * Creates a cluster definition which contains cluster configuration.
24
- * @param {ClusterPayload} newCluster - The new unique cluster.
25
- * @returns {Promise<string>} config_hash.
26
- * @throws On duplicate entries, missing or wrong cluster keys.
27
- *
28
- * An example of how to use createClusterDefinition:
29
- * [createObolCluster](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
30
- */
31
- createClusterDefinition(newCluster: ClusterPayload): Promise<string>;
32
- /**
33
- * Approves joining a cluster with specific configuration.
34
- * @param {OperatorPayload} operatorPayload - The operator data including signatures.
35
- * @param {string} configHash - The config hash of the cluster which the operator confirms joining to.
36
- * @returns {Promise<ClusterDefintion>} The cluster definition.
37
- * @throws On unauthorized, duplicate entries, missing keys, not found cluster or invalid data.
38
- *
39
- * An example of how to use updateClusterDefinition:
40
- * [updateClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
41
- */
42
- updateClusterDefinition(operatorPayload: OperatorPayload, configHash: string): Promise<ClusterDefintion>;
43
- /**
44
- * @returns {Promise<ClusterDefintion>} The cluster definition for config hash
45
- * @throws On not found config hash.
46
- *
47
- * An example of how to use getClusterDefinition:
48
- * [getObolClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
49
- */
50
- getClusterDefinition(configHash: string): Promise<ClusterDefintion>;
51
- /**
52
- * @returns {Promise<ClusterLock>} The matched cluster details (lock) from DB
53
- * @throws On not found cluster definition or lock.
54
- *
55
- * An example of how to use getClusterLock:
56
- * [getObolClusterLock](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
57
- */
58
- getClusterLock(configHash: string): Promise<ClusterLock>;
59
- }
60
- //# sourceMappingURL=index.d.ts.map
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>;