@ssv-labs/ssv-sdk 0.0.7 → 0.1.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/KeyShares-7biQfDev.js +19422 -0
- package/dist/KeyShares-DEqBZits.mjs +19423 -0
- package/dist/api/subgraph/index.d.ts +15 -54
- package/dist/config/chains.d.ts +18 -10
- package/dist/globals-BZbDG7rK.mjs +472 -0
- package/dist/globals-iY-Y-uDY.js +471 -0
- package/dist/graphql/graphql.d.ts +10 -33
- package/dist/keys.js +9 -0
- package/dist/keys.mjs +9 -0
- package/dist/libs/api/index.d.ts +9 -69
- package/dist/libs/cluster/index.d.ts +11 -5638
- package/dist/libs/cluster/methods/deposit.d.ts +1 -1
- package/dist/libs/cluster/methods/exit-validators.d.ts +1 -1
- package/dist/libs/cluster/methods/liquidate-cluster.d.ts +1 -1
- package/dist/libs/cluster/methods/reactivate-cluster.d.ts +1 -1
- package/dist/libs/cluster/methods/register-validators.d.ts +3 -2
- package/dist/libs/cluster/methods/remove-validators.d.ts +1 -1
- package/dist/libs/cluster/methods/set-fee-recipient.d.ts +1 -1
- package/dist/libs/cluster/methods/withdraw.d.ts +1 -1
- package/dist/libs/operator/index.d.ts +94 -911
- package/dist/libs/operator/methods.d.ts +3 -3
- package/dist/libs/ssv-keys/BLS/index.d.ts +2 -0
- package/dist/libs/ssv-keys/Encryption/Encryption.d.ts +7 -0
- package/dist/libs/ssv-keys/Encryption/__test__/RsaKeys.d.ts +3 -0
- package/dist/libs/ssv-keys/Encryption/utils.d.ts +55 -0
- package/dist/libs/ssv-keys/EthereumKeyStore/EthereumKeyStore.d.ts +23 -0
- package/dist/libs/ssv-keys/EthereumKeyStore/index.d.ts +1 -0
- package/dist/libs/ssv-keys/KeyShares/KeyShares.d.ts +32 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/KeySharesData.d.ts +21 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/KeySharesPayload.d.ts +32 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/OperatorData.d.ts +10 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/encrypted-key.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/index.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/match.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/operator-public-key.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/operator-unique.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/owner-address.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/owner-nonce.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/public-key.d.ts +6 -0
- package/dist/libs/ssv-keys/KeyShares/KeySharesItem.d.ts +60 -0
- package/dist/libs/ssv-keys/SSVKeys.d.ts +66 -0
- package/dist/libs/ssv-keys/Threshold/Threshold.d.ts +28 -0
- package/dist/libs/ssv-keys/Threshold/__test__/helper/share_signatures.d.ts +7 -0
- package/dist/libs/ssv-keys/Threshold/index.d.ts +1 -0
- package/dist/libs/ssv-keys/exceptions/base.d.ts +4 -0
- package/dist/libs/ssv-keys/exceptions/bls.d.ts +9 -0
- package/dist/libs/ssv-keys/exceptions/index.d.ts +2 -0
- package/dist/libs/ssv-keys/exceptions/keyshares.d.ts +5 -0
- package/dist/libs/ssv-keys/exceptions/keystore.d.ts +27 -0
- package/dist/libs/ssv-keys/exceptions/operator.d.ts +22 -0
- package/dist/libs/ssv-keys/helpers/operator.helper.d.ts +7 -0
- package/dist/libs/ssv-keys/helpers/web3.helper.d.ts +36 -0
- package/dist/libs/ssv-keys/index.d.ts +4 -0
- package/dist/libs/ssv-keys/interfaces/IEncryptShare.d.ts +5 -0
- package/dist/libs/ssv-keys/interfaces/IKeySharesData.d.ts +18 -0
- package/dist/libs/ssv-keys/interfaces/IKeySharesPayload.d.ts +13 -0
- package/dist/libs/ssv-keys/interfaces/IOperator.d.ts +4 -0
- package/dist/libs/ssv-keys/interfaces/IOperatorData.d.ts +5 -0
- package/dist/libs/ssv-keys/interfaces/IShares.d.ts +10 -0
- package/dist/libs/ssv-keys/interfaces/index.d.ts +6 -0
- package/dist/libs/ssv-keys/validators/index.d.ts +2 -0
- package/dist/libs/ssv-keys/validators/operatorPublicKey.validator.d.ts +1 -0
- package/dist/libs/ssv-keys/validators/operatorsLength.validator.d.ts +1 -0
- package/dist/libs/utils/index.d.ts +8 -18
- package/dist/libs/utils/methods/keyshares.d.ts +5 -2
- package/dist/libs/utils/methods/keystores.d.ts +2 -2
- package/dist/main.d.ts +1 -0
- package/dist/main.js +4389 -34564
- package/dist/main.mjs +4389 -34563
- package/dist/mock/api.d.ts +1 -1
- package/dist/types/contract-interactions.d.ts +2 -2
- package/dist/utils/cluster.d.ts +1 -1
- package/dist/utils/contract.d.ts +2 -1
- package/dist/utils/keyshares.d.ts +2 -2
- package/dist/utils/number.d.ts +1 -1
- package/dist/utils/zod/config.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +34 -34
- package/package.json +24 -9
- package/dist/globals-BHuFvs8-.mjs +0 -5511
- package/dist/globals-DCoa7oI7.js +0 -5509
|
@@ -15,7 +15,7 @@ export declare const getCluster: (client: GraphQLClient, args: GetClusterQueryVa
|
|
|
15
15
|
balance: string;
|
|
16
16
|
index: string;
|
|
17
17
|
networkFeeIndex: string;
|
|
18
|
-
operatorIds: string
|
|
18
|
+
operatorIds: Array<string>;
|
|
19
19
|
} | null | undefined>;
|
|
20
20
|
export declare const getClusters: (client: GraphQLClient, args: GetClustersQueryVariables) => Promise<{
|
|
21
21
|
id: string;
|
|
@@ -24,7 +24,7 @@ export declare const getClusters: (client: GraphQLClient, args: GetClustersQuery
|
|
|
24
24
|
balance: string;
|
|
25
25
|
index: string;
|
|
26
26
|
networkFeeIndex: string;
|
|
27
|
-
operatorIds: string
|
|
27
|
+
operatorIds: Array<string>;
|
|
28
28
|
}[]>;
|
|
29
29
|
export declare const getOperator: (client: GraphQLClient, args: GetOperatorQueryVariables) => Promise<{
|
|
30
30
|
publicKey: string;
|
|
@@ -32,7 +32,7 @@ export declare const getOperator: (client: GraphQLClient, args: GetOperatorQuery
|
|
|
32
32
|
id: string;
|
|
33
33
|
validatorCount: string;
|
|
34
34
|
isPrivate: boolean;
|
|
35
|
-
whitelistedContract:
|
|
35
|
+
whitelistedContract: import('abitype').Address;
|
|
36
36
|
} | null>;
|
|
37
37
|
export declare const getOperators: (client: GraphQLClient, args: GetOperatorsQueryVariables) => Promise<{
|
|
38
38
|
publicKey: string;
|
|
@@ -40,62 +40,23 @@ export declare const getOperators: (client: GraphQLClient, args: GetOperatorsQue
|
|
|
40
40
|
id: string;
|
|
41
41
|
validatorCount: string;
|
|
42
42
|
isPrivate: boolean;
|
|
43
|
-
whitelistedContract:
|
|
43
|
+
whitelistedContract: import('abitype').Address;
|
|
44
44
|
}[]>;
|
|
45
45
|
export declare const getValidators: (client: GraphQLClient, args: GetValidatorsQueryVariables) => Promise<{
|
|
46
|
-
id:
|
|
46
|
+
id: import('abitype').Address;
|
|
47
47
|
}[]>;
|
|
48
48
|
export declare const getValidator: (client: GraphQLClient, args: GetValidatorQueryVariables) => Promise<{
|
|
49
|
-
id:
|
|
49
|
+
id: import('abitype').Address;
|
|
50
50
|
} | null | undefined>;
|
|
51
51
|
export declare const getClusterBalance: (client: GraphQLClient, args: GetClusterBalanceQueryVariables) => Promise<import('../../graphql/graphql').GetClusterBalanceQuery>;
|
|
52
52
|
export declare const getQueries: (client: GraphQLClient) => {
|
|
53
|
-
getOwnerNonce: RemoveConfigArg<
|
|
54
|
-
getClusterSnapshot: RemoveConfigArg<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
active: boolean;
|
|
63
|
-
validatorCount: string;
|
|
64
|
-
balance: string;
|
|
65
|
-
index: string;
|
|
66
|
-
networkFeeIndex: string;
|
|
67
|
-
operatorIds: string[];
|
|
68
|
-
} | null | undefined>>;
|
|
69
|
-
getClusters: RemoveConfigArg<(client: GraphQLClient, args: GetClustersQueryVariables) => Promise<{
|
|
70
|
-
id: string;
|
|
71
|
-
active: boolean;
|
|
72
|
-
validatorCount: string;
|
|
73
|
-
balance: string;
|
|
74
|
-
index: string;
|
|
75
|
-
networkFeeIndex: string;
|
|
76
|
-
operatorIds: string[];
|
|
77
|
-
}[]>>;
|
|
78
|
-
getOperator: RemoveConfigArg<(client: GraphQLClient, args: GetOperatorQueryVariables) => Promise<{
|
|
79
|
-
publicKey: string;
|
|
80
|
-
whitelisted: `0x${string}`[];
|
|
81
|
-
id: string;
|
|
82
|
-
validatorCount: string;
|
|
83
|
-
isPrivate: boolean;
|
|
84
|
-
whitelistedContract: `0x${string}`;
|
|
85
|
-
} | null>>;
|
|
86
|
-
getOperators: RemoveConfigArg<(client: GraphQLClient, args: GetOperatorsQueryVariables) => Promise<{
|
|
87
|
-
publicKey: string;
|
|
88
|
-
whitelisted: `0x${string}`[];
|
|
89
|
-
id: string;
|
|
90
|
-
validatorCount: string;
|
|
91
|
-
isPrivate: boolean;
|
|
92
|
-
whitelistedContract: `0x${string}`;
|
|
93
|
-
}[]>>;
|
|
94
|
-
getValidators: RemoveConfigArg<(client: GraphQLClient, args: GetValidatorsQueryVariables) => Promise<{
|
|
95
|
-
id: `0x${string}`;
|
|
96
|
-
}[]>>;
|
|
97
|
-
getValidator: RemoveConfigArg<(client: GraphQLClient, args: GetValidatorQueryVariables) => Promise<{
|
|
98
|
-
id: `0x${string}`;
|
|
99
|
-
} | null | undefined>>;
|
|
100
|
-
getClusterBalance: RemoveConfigArg<(client: GraphQLClient, args: GetClusterBalanceQueryVariables) => Promise<import('../../graphql/graphql').GetClusterBalanceQuery>>;
|
|
53
|
+
getOwnerNonce: RemoveConfigArg<typeof getOwnerNonce>;
|
|
54
|
+
getClusterSnapshot: RemoveConfigArg<typeof getClusterSnapshot>;
|
|
55
|
+
getCluster: RemoveConfigArg<typeof getCluster>;
|
|
56
|
+
getClusters: RemoveConfigArg<typeof getClusters>;
|
|
57
|
+
getOperator: RemoveConfigArg<typeof getOperator>;
|
|
58
|
+
getOperators: RemoveConfigArg<typeof getOperators>;
|
|
59
|
+
getValidators: RemoveConfigArg<typeof getValidators>;
|
|
60
|
+
getValidator: RemoveConfigArg<typeof getValidator>;
|
|
61
|
+
getClusterBalance: RemoveConfigArg<typeof getClusterBalance>;
|
|
101
62
|
};
|
package/dist/config/chains.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ export declare const hoodi: {
|
|
|
11
11
|
url: string;
|
|
12
12
|
apiUrl?: string | undefined;
|
|
13
13
|
};
|
|
14
|
-
} | undefined;
|
|
14
|
+
} | undefined | undefined;
|
|
15
|
+
blockTime?: number | undefined | undefined;
|
|
15
16
|
contracts?: {
|
|
16
17
|
[x: string]: import('viem').ChainContract | {
|
|
17
18
|
[sourceId: number]: import('viem').ChainContract | undefined;
|
|
@@ -21,6 +22,7 @@ export declare const hoodi: {
|
|
|
21
22
|
multicall3?: import('viem').ChainContract | undefined;
|
|
22
23
|
universalSignatureVerifier?: import('viem').ChainContract | undefined;
|
|
23
24
|
} | undefined;
|
|
25
|
+
ensTlds?: readonly string[] | undefined;
|
|
24
26
|
id: 560048;
|
|
25
27
|
name: "Hoodi";
|
|
26
28
|
nativeCurrency: {
|
|
@@ -33,7 +35,7 @@ export declare const hoodi: {
|
|
|
33
35
|
readonly http: readonly ["https://rpc.hoodi.ethpandaops.io"];
|
|
34
36
|
};
|
|
35
37
|
};
|
|
36
|
-
sourceId?: number | undefined;
|
|
38
|
+
sourceId?: number | undefined | undefined;
|
|
37
39
|
testnet: true;
|
|
38
40
|
custom?: Record<string, unknown> | undefined;
|
|
39
41
|
fees?: import('viem').ChainFees<undefined> | undefined;
|
|
@@ -49,6 +51,7 @@ export declare const chains: {
|
|
|
49
51
|
readonly apiUrl: "https://api.etherscan.io/api";
|
|
50
52
|
};
|
|
51
53
|
};
|
|
54
|
+
blockTime?: number | undefined | undefined;
|
|
52
55
|
contracts: {
|
|
53
56
|
readonly ensRegistry: {
|
|
54
57
|
readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
@@ -62,6 +65,7 @@ export declare const chains: {
|
|
|
62
65
|
readonly blockCreated: 14353601;
|
|
63
66
|
};
|
|
64
67
|
};
|
|
68
|
+
ensTlds?: readonly string[] | undefined;
|
|
65
69
|
id: 1;
|
|
66
70
|
name: "Ethereum";
|
|
67
71
|
nativeCurrency: {
|
|
@@ -71,15 +75,15 @@ export declare const chains: {
|
|
|
71
75
|
};
|
|
72
76
|
rpcUrls: {
|
|
73
77
|
readonly default: {
|
|
74
|
-
readonly http: readonly ["https://
|
|
78
|
+
readonly http: readonly ["https://eth.merkle.io"];
|
|
75
79
|
};
|
|
76
80
|
};
|
|
77
|
-
sourceId?: number | undefined;
|
|
78
|
-
testnet?: boolean | undefined;
|
|
81
|
+
sourceId?: number | undefined | undefined;
|
|
82
|
+
testnet?: boolean | undefined | undefined;
|
|
79
83
|
custom?: Record<string, unknown> | undefined;
|
|
80
84
|
fees?: import('viem').ChainFees<undefined> | undefined;
|
|
81
85
|
formatters?: undefined;
|
|
82
|
-
serializers?: import('viem').ChainSerializers<undefined, import('viem').TransactionSerializable
|
|
86
|
+
serializers?: import('viem').ChainSerializers<undefined, import('viem').TransactionSerializable> | undefined;
|
|
83
87
|
};
|
|
84
88
|
readonly holesky: {
|
|
85
89
|
blockExplorers: {
|
|
@@ -89,6 +93,7 @@ export declare const chains: {
|
|
|
89
93
|
readonly apiUrl: "https://api-holesky.etherscan.io/api";
|
|
90
94
|
};
|
|
91
95
|
};
|
|
96
|
+
blockTime?: number | undefined | undefined;
|
|
92
97
|
contracts: {
|
|
93
98
|
readonly multicall3: {
|
|
94
99
|
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
@@ -103,6 +108,7 @@ export declare const chains: {
|
|
|
103
108
|
readonly blockCreated: 973484;
|
|
104
109
|
};
|
|
105
110
|
};
|
|
111
|
+
ensTlds?: readonly string[] | undefined;
|
|
106
112
|
id: 17000;
|
|
107
113
|
name: "Holesky";
|
|
108
114
|
nativeCurrency: {
|
|
@@ -115,12 +121,12 @@ export declare const chains: {
|
|
|
115
121
|
readonly http: readonly ["https://ethereum-holesky-rpc.publicnode.com"];
|
|
116
122
|
};
|
|
117
123
|
};
|
|
118
|
-
sourceId?: number | undefined;
|
|
124
|
+
sourceId?: number | undefined | undefined;
|
|
119
125
|
testnet: true;
|
|
120
126
|
custom?: Record<string, unknown> | undefined;
|
|
121
127
|
fees?: import('viem').ChainFees<undefined> | undefined;
|
|
122
128
|
formatters?: undefined;
|
|
123
|
-
serializers?: import('viem').ChainSerializers<undefined, import('viem').TransactionSerializable
|
|
129
|
+
serializers?: import('viem').ChainSerializers<undefined, import('viem').TransactionSerializable> | undefined;
|
|
124
130
|
};
|
|
125
131
|
readonly hoodi: {
|
|
126
132
|
blockExplorers?: {
|
|
@@ -134,7 +140,8 @@ export declare const chains: {
|
|
|
134
140
|
url: string;
|
|
135
141
|
apiUrl?: string | undefined;
|
|
136
142
|
};
|
|
137
|
-
} | undefined;
|
|
143
|
+
} | undefined | undefined;
|
|
144
|
+
blockTime?: number | undefined | undefined;
|
|
138
145
|
contracts?: {
|
|
139
146
|
[x: string]: import('viem').ChainContract | {
|
|
140
147
|
[sourceId: number]: import('viem').ChainContract | undefined;
|
|
@@ -144,6 +151,7 @@ export declare const chains: {
|
|
|
144
151
|
multicall3?: import('viem').ChainContract | undefined;
|
|
145
152
|
universalSignatureVerifier?: import('viem').ChainContract | undefined;
|
|
146
153
|
} | undefined;
|
|
154
|
+
ensTlds?: readonly string[] | undefined;
|
|
147
155
|
id: 560048;
|
|
148
156
|
name: "Hoodi";
|
|
149
157
|
nativeCurrency: {
|
|
@@ -156,7 +164,7 @@ export declare const chains: {
|
|
|
156
164
|
readonly http: readonly ["https://rpc.hoodi.ethpandaops.io"];
|
|
157
165
|
};
|
|
158
166
|
};
|
|
159
|
-
sourceId?: number | undefined;
|
|
167
|
+
sourceId?: number | undefined | undefined;
|
|
160
168
|
testnet: true;
|
|
161
169
|
custom?: Record<string, unknown> | undefined;
|
|
162
170
|
fees?: import('viem').ChainFees<undefined> | undefined;
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { isUndefined, cloneDeepWith, merge } from "lodash-es";
|
|
2
|
+
import { formatUnits, decodeAbiParameters, defineChain as defineChain$1, parseUnits, isAddress } from "viem";
|
|
3
|
+
import "graphql-request";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
const numberFormatter = new Intl.NumberFormat("en-US", {
|
|
6
|
+
useGrouping: true,
|
|
7
|
+
maximumFractionDigits: 2
|
|
8
|
+
});
|
|
9
|
+
const _percentageFormatter = new Intl.NumberFormat("en-US", {
|
|
10
|
+
style: "percent",
|
|
11
|
+
maximumFractionDigits: 2
|
|
12
|
+
});
|
|
13
|
+
const percentageFormatter = {
|
|
14
|
+
format: (value) => {
|
|
15
|
+
if (!value) return "0%";
|
|
16
|
+
return _percentageFormatter.format(value / 100);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const bigintFormatter = new Intl.NumberFormat("en-US", {
|
|
20
|
+
useGrouping: false,
|
|
21
|
+
maximumFractionDigits: 7
|
|
22
|
+
});
|
|
23
|
+
const ethFormatter = new Intl.NumberFormat("en-US", {
|
|
24
|
+
useGrouping: true,
|
|
25
|
+
maximumFractionDigits: 4
|
|
26
|
+
});
|
|
27
|
+
const formatSSV = (num, decimals = 18) => ethFormatter.format(+formatUnits(num, decimals));
|
|
28
|
+
const formatBigintInput = (num, decimals = 18) => bigintFormatter.format(+formatUnits(num, decimals));
|
|
29
|
+
const units = {
|
|
30
|
+
seconds: 1e3,
|
|
31
|
+
minutes: 6e4,
|
|
32
|
+
hours: 36e5,
|
|
33
|
+
days: 864e5,
|
|
34
|
+
weeks: 6048e5,
|
|
35
|
+
months: 2629746e3,
|
|
36
|
+
years: 31556952e3
|
|
37
|
+
};
|
|
38
|
+
const ms = (value, unit) => {
|
|
39
|
+
return value * units[unit];
|
|
40
|
+
};
|
|
41
|
+
const sortNumbers = (numbers) => {
|
|
42
|
+
return [...numbers].sort((a, b) => Number(a) - Number(b));
|
|
43
|
+
};
|
|
44
|
+
const getOperatorIds = (operators) => {
|
|
45
|
+
return sortNumbers(operators.map((operator) => operator.id));
|
|
46
|
+
};
|
|
47
|
+
const decodeOperatorPublicKey = (publicKey) => {
|
|
48
|
+
return decodeAbiParameters([{ type: "string" }], publicKey)[0];
|
|
49
|
+
};
|
|
50
|
+
function defineChain(chain) {
|
|
51
|
+
return {
|
|
52
|
+
formatters: void 0,
|
|
53
|
+
fees: void 0,
|
|
54
|
+
serializers: void 0,
|
|
55
|
+
...chain
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const holesky = /* @__PURE__ */ defineChain({
|
|
59
|
+
id: 17e3,
|
|
60
|
+
name: "Holesky",
|
|
61
|
+
nativeCurrency: { name: "Holesky Ether", symbol: "ETH", decimals: 18 },
|
|
62
|
+
rpcUrls: {
|
|
63
|
+
default: {
|
|
64
|
+
http: ["https://ethereum-holesky-rpc.publicnode.com"]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
blockExplorers: {
|
|
68
|
+
default: {
|
|
69
|
+
name: "Etherscan",
|
|
70
|
+
url: "https://holesky.etherscan.io",
|
|
71
|
+
apiUrl: "https://api-holesky.etherscan.io/api"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
contracts: {
|
|
75
|
+
multicall3: {
|
|
76
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
77
|
+
blockCreated: 77
|
|
78
|
+
},
|
|
79
|
+
ensRegistry: {
|
|
80
|
+
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
|
|
81
|
+
blockCreated: 801613
|
|
82
|
+
},
|
|
83
|
+
ensUniversalResolver: {
|
|
84
|
+
address: "0xa6AC935D4971E3CD133b950aE053bECD16fE7f3b",
|
|
85
|
+
blockCreated: 973484
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
testnet: true
|
|
89
|
+
});
|
|
90
|
+
const mainnet = /* @__PURE__ */ defineChain({
|
|
91
|
+
id: 1,
|
|
92
|
+
name: "Ethereum",
|
|
93
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
94
|
+
rpcUrls: {
|
|
95
|
+
default: {
|
|
96
|
+
http: ["https://eth.merkle.io"]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
blockExplorers: {
|
|
100
|
+
default: {
|
|
101
|
+
name: "Etherscan",
|
|
102
|
+
url: "https://etherscan.io",
|
|
103
|
+
apiUrl: "https://api.etherscan.io/api"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
contracts: {
|
|
107
|
+
ensRegistry: {
|
|
108
|
+
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
|
|
109
|
+
},
|
|
110
|
+
ensUniversalResolver: {
|
|
111
|
+
address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67",
|
|
112
|
+
blockCreated: 19258213
|
|
113
|
+
},
|
|
114
|
+
multicall3: {
|
|
115
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
116
|
+
blockCreated: 14353601
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const hoodi = defineChain$1({
|
|
121
|
+
id: 560048,
|
|
122
|
+
name: "Hoodi",
|
|
123
|
+
rpcUrls: {
|
|
124
|
+
default: {
|
|
125
|
+
http: ["https://rpc.hoodi.ethpandaops.io"]
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
nativeCurrency: {
|
|
129
|
+
name: "Hoodi Ether",
|
|
130
|
+
symbol: "ETH",
|
|
131
|
+
decimals: 18
|
|
132
|
+
},
|
|
133
|
+
testnet: true
|
|
134
|
+
});
|
|
135
|
+
const chains = {
|
|
136
|
+
mainnet,
|
|
137
|
+
holesky,
|
|
138
|
+
hoodi
|
|
139
|
+
};
|
|
140
|
+
const chainIds = Object.values(chains).map((chain) => chain.id);
|
|
141
|
+
const networks = Object.values(chains).map((chain) => chain.name);
|
|
142
|
+
const graph_endpoints = {
|
|
143
|
+
[mainnet.id]: "https://api.studio.thegraph.com/query/71118/ssv-network-ethereum/version/latest",
|
|
144
|
+
[holesky.id]: "https://api.studio.thegraph.com/query/71118/ssv-network-holesky/version/latest",
|
|
145
|
+
[hoodi.id]: "https://graph-node-hoodi.stage.ops.ssvlabsinternal.com/subgraphs/name/ssv-bapps-hoodi"
|
|
146
|
+
};
|
|
147
|
+
const rest_endpoints = {
|
|
148
|
+
[mainnet.id]: "https://api.ssv.network/api/v4/mainnet",
|
|
149
|
+
[holesky.id]: "https://api.ssv.network/api/v4/holesky",
|
|
150
|
+
[hoodi.id]: "https://api.ssv.network/api/v4/hoodi"
|
|
151
|
+
};
|
|
152
|
+
const contracts = {
|
|
153
|
+
[mainnet.id]: {
|
|
154
|
+
setter: "0xDD9BC35aE942eF0cFa76930954a156B3fF30a4E1",
|
|
155
|
+
getter: "0xafE830B6Ee262ba11cce5F32fDCd760FFE6a66e4",
|
|
156
|
+
token: "0x9D65fF81a3c488d585bBfb0Bfe3c7707c7917f54"
|
|
157
|
+
},
|
|
158
|
+
[holesky.id]: {
|
|
159
|
+
setter: "0x38A4794cCEd47d3baf7370CcC43B560D3a1beEFA",
|
|
160
|
+
getter: "0x352A18AEe90cdcd825d1E37d9939dCA86C00e281",
|
|
161
|
+
token: "0xad45A78180961079BFaeEe349704F411dfF947C6"
|
|
162
|
+
},
|
|
163
|
+
[hoodi.id]: {
|
|
164
|
+
setter: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c",
|
|
165
|
+
getter: "0x5AdDb3f1529C5ec70D77400499eE4bbF328368fe",
|
|
166
|
+
token: "0x9F5d4Ec84fC4785788aB44F9de973cF34F7A038e"
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const bigintMax = (...args) => {
|
|
170
|
+
return args.filter((x) => !isUndefined(x)).reduce((max, cur) => cur > max ? cur : max);
|
|
171
|
+
};
|
|
172
|
+
const bigintMin = (...args) => {
|
|
173
|
+
return args.filter((x) => !isUndefined(x)).reduce((min, cur) => cur < min ? cur : min);
|
|
174
|
+
};
|
|
175
|
+
const bigintRound = (value, precision) => {
|
|
176
|
+
const remainder = value % precision;
|
|
177
|
+
return remainder >= precision / 2n ? value + (precision - remainder) : value - remainder;
|
|
178
|
+
};
|
|
179
|
+
const bigintFloor = (value, precision = 10000000n) => {
|
|
180
|
+
return value - value % precision;
|
|
181
|
+
};
|
|
182
|
+
const bigintAbs = (n) => n < 0n ? -n : n;
|
|
183
|
+
const isBigIntChanged = (a, b, tolerance = parseUnits("0.0001", 18)) => {
|
|
184
|
+
return bigintAbs(a - b) > tolerance;
|
|
185
|
+
};
|
|
186
|
+
const roundOperatorFee = (fee, precision = 10000000n) => {
|
|
187
|
+
return bigintRound(fee, precision);
|
|
188
|
+
};
|
|
189
|
+
const stringifyBigints = (anything) => {
|
|
190
|
+
return cloneDeepWith(anything, (value) => {
|
|
191
|
+
if (typeof value === "bigint") return value.toString();
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const bigintifyNumbers = (numbers) => {
|
|
195
|
+
return cloneDeepWith(numbers, (value) => {
|
|
196
|
+
if (typeof value === "number") return BigInt(value);
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
const createClusterId = (ownerAddress, operatorIds) => {
|
|
200
|
+
if (!isAddress(ownerAddress)) {
|
|
201
|
+
throw new Error("Invalid owner address");
|
|
202
|
+
}
|
|
203
|
+
return `${ownerAddress.toLowerCase()}-${operatorIds.join("-")}`;
|
|
204
|
+
};
|
|
205
|
+
const isClusterId = (clusterId) => {
|
|
206
|
+
const [ownerAddress, ...operatorIds] = clusterId.split("-");
|
|
207
|
+
return isAddress(ownerAddress) && operatorIds.length >= 4 && operatorIds.every((id) => !isNaN(Number(id)));
|
|
208
|
+
};
|
|
209
|
+
const getClusterSnapshot = (cluster) => {
|
|
210
|
+
return {
|
|
211
|
+
active: cluster.active,
|
|
212
|
+
balance: BigInt(cluster.balance),
|
|
213
|
+
index: BigInt(cluster.index),
|
|
214
|
+
networkFeeIndex: BigInt(cluster.networkFeeIndex),
|
|
215
|
+
validatorCount: +cluster.validatorCount
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
const createEmptyCluster = (cluster = {}) => merge(
|
|
219
|
+
{
|
|
220
|
+
validatorCount: 0,
|
|
221
|
+
networkFeeIndex: 0n,
|
|
222
|
+
index: 0n,
|
|
223
|
+
balance: 0n,
|
|
224
|
+
active: true
|
|
225
|
+
},
|
|
226
|
+
cluster
|
|
227
|
+
);
|
|
228
|
+
const add0x = (value) => !value.startsWith("0x") ? `0x${value}` : value;
|
|
229
|
+
const isKeySharesItem = (item) => {
|
|
230
|
+
return !!item && typeof item === "object" && "data" in item && "payload" in item && "error" in item;
|
|
231
|
+
};
|
|
232
|
+
var KeysharesValidationErrors = /* @__PURE__ */ ((KeysharesValidationErrors2) => {
|
|
233
|
+
KeysharesValidationErrors2[KeysharesValidationErrors2["OperatorDoesNotExist"] = 0] = "OperatorDoesNotExist";
|
|
234
|
+
KeysharesValidationErrors2[KeysharesValidationErrors2["OperatorMismatch"] = 1] = "OperatorMismatch";
|
|
235
|
+
KeysharesValidationErrors2[KeysharesValidationErrors2["ValidatorAlreadyExists"] = 2] = "ValidatorAlreadyExists";
|
|
236
|
+
KeysharesValidationErrors2[KeysharesValidationErrors2["ClusterMismatch"] = 3] = "ClusterMismatch";
|
|
237
|
+
KeysharesValidationErrors2[KeysharesValidationErrors2["DuplicateValidatorKeys"] = 4] = "DuplicateValidatorKeys";
|
|
238
|
+
KeysharesValidationErrors2[KeysharesValidationErrors2["InconsistentOperatorPublicKeys"] = 5] = "InconsistentOperatorPublicKeys";
|
|
239
|
+
KeysharesValidationErrors2[KeysharesValidationErrors2["InconsistentOperators"] = 6] = "InconsistentOperators";
|
|
240
|
+
return KeysharesValidationErrors2;
|
|
241
|
+
})(KeysharesValidationErrors || {});
|
|
242
|
+
const KeysharesValidationErrorsMessages = {
|
|
243
|
+
[
|
|
244
|
+
0
|
|
245
|
+
/* OperatorDoesNotExist */
|
|
246
|
+
]: "Operator not found. Please verify the operator ID.",
|
|
247
|
+
[
|
|
248
|
+
1
|
|
249
|
+
/* OperatorMismatch */
|
|
250
|
+
]: "Operator details mismatch. Check provided information.",
|
|
251
|
+
[
|
|
252
|
+
2
|
|
253
|
+
/* ValidatorAlreadyExists */
|
|
254
|
+
]: "Validator public key already in use. Must be unique.",
|
|
255
|
+
[
|
|
256
|
+
3
|
|
257
|
+
/* ClusterMismatch */
|
|
258
|
+
]: "The operators in the provided keyshares do not match the provided operators. Please ensure the keyshares correspond to the cluster you are trying to register.",
|
|
259
|
+
[
|
|
260
|
+
4
|
|
261
|
+
/* DuplicateValidatorKeys */
|
|
262
|
+
]: "Duplicate validator keys detected. Each must be unique.",
|
|
263
|
+
[
|
|
264
|
+
5
|
|
265
|
+
/* InconsistentOperatorPublicKeys */
|
|
266
|
+
]: "Operator public keys mismatch. Verify operator data.",
|
|
267
|
+
[
|
|
268
|
+
6
|
|
269
|
+
/* InconsistentOperators */
|
|
270
|
+
]: "Inconsistent operator IDs across keyshares. Check all entries."
|
|
271
|
+
};
|
|
272
|
+
class KeysharesValidationError extends Error {
|
|
273
|
+
constructor(code) {
|
|
274
|
+
super(KeysharesValidationErrorsMessages[code]);
|
|
275
|
+
this.code = code;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const validateConsistentOperatorIds = (keyshares) => {
|
|
279
|
+
const operatorIds = sortNumbers(keyshares[0].payload.operatorIds);
|
|
280
|
+
keyshares.every(({ payload, data }) => {
|
|
281
|
+
const payloadOperatorIds = sortNumbers(payload.operatorIds).toString();
|
|
282
|
+
const dataOperatorIds = getOperatorIds(data.operators ?? []).toString();
|
|
283
|
+
const valid = payloadOperatorIds === dataOperatorIds && dataOperatorIds === operatorIds.toString();
|
|
284
|
+
if (!valid) {
|
|
285
|
+
throw new KeysharesValidationError(
|
|
286
|
+
6
|
|
287
|
+
/* InconsistentOperators */
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
});
|
|
292
|
+
return operatorIds;
|
|
293
|
+
};
|
|
294
|
+
const ensureValidatorsUniqueness = (keyshares) => {
|
|
295
|
+
const set = new Set(keyshares.map(({ data }) => data.publicKey));
|
|
296
|
+
if (set.size !== keyshares.length) {
|
|
297
|
+
throw new KeysharesValidationError(
|
|
298
|
+
4
|
|
299
|
+
/* DuplicateValidatorKeys */
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
return true;
|
|
303
|
+
};
|
|
304
|
+
const validateConsistentOperatorPublicKeys = (keyshares, operators) => {
|
|
305
|
+
const operatorsMap = new Map(operators.map((o) => [o.id, o.publicKey]));
|
|
306
|
+
const valid = keyshares.every(({ data }) => {
|
|
307
|
+
return data.operators?.every(({ id, operatorKey }) => {
|
|
308
|
+
return operatorsMap.get(id.toString()) === operatorKey;
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
if (!valid) {
|
|
312
|
+
throw new KeysharesValidationError(
|
|
313
|
+
5
|
|
314
|
+
/* InconsistentOperatorPublicKeys */
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
return valid;
|
|
318
|
+
};
|
|
319
|
+
const ensureNoKeysharesErrors = (keyshares) => {
|
|
320
|
+
keyshares.forEach((share) => {
|
|
321
|
+
if (share.error) {
|
|
322
|
+
throw share.error;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return true;
|
|
326
|
+
};
|
|
327
|
+
const tryCatch = (fn) => {
|
|
328
|
+
try {
|
|
329
|
+
return [fn(), null];
|
|
330
|
+
} catch (e) {
|
|
331
|
+
return [null, e];
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const configArgsSchema = z.object({
|
|
335
|
+
publicClient: z.custom().superRefine((val, ctx) => {
|
|
336
|
+
const client = val;
|
|
337
|
+
if (!client) {
|
|
338
|
+
ctx.addIssue({
|
|
339
|
+
code: z.ZodIssueCode.custom,
|
|
340
|
+
message: "Public client must be provided"
|
|
341
|
+
});
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
if (client.chain === void 0) {
|
|
345
|
+
ctx.addIssue({
|
|
346
|
+
code: z.ZodIssueCode.custom,
|
|
347
|
+
message: "Public client must have a chain property"
|
|
348
|
+
});
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
if (!chainIds.includes(client.chain?.id)) {
|
|
352
|
+
ctx.addIssue({
|
|
353
|
+
code: z.ZodIssueCode.custom,
|
|
354
|
+
message: `Public client chain must be one of [${networks.join(", ")}]`
|
|
355
|
+
});
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
return true;
|
|
359
|
+
}),
|
|
360
|
+
walletClient: z.custom().superRefine((val, ctx) => {
|
|
361
|
+
const client = val;
|
|
362
|
+
if (!client) {
|
|
363
|
+
ctx.addIssue({
|
|
364
|
+
code: z.ZodIssueCode.custom,
|
|
365
|
+
message: "Wallet client must be provided"
|
|
366
|
+
});
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
if (client.chain === void 0) {
|
|
370
|
+
ctx.addIssue({
|
|
371
|
+
code: z.ZodIssueCode.custom,
|
|
372
|
+
message: "Wallet client must have a chain property"
|
|
373
|
+
});
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
if (!chainIds.includes(client.chain?.id)) {
|
|
377
|
+
ctx.addIssue({
|
|
378
|
+
code: z.ZodIssueCode.custom,
|
|
379
|
+
message: `Wallet client chain must be one of [${networks.join(", ")}]`
|
|
380
|
+
});
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
return true;
|
|
384
|
+
}),
|
|
385
|
+
_: z.object({
|
|
386
|
+
graphUrl: z.string().url().optional(),
|
|
387
|
+
restUrl: z.string().url().optional(),
|
|
388
|
+
contractAddresses: z.object({
|
|
389
|
+
setter: z.string().optional(),
|
|
390
|
+
getter: z.string().optional(),
|
|
391
|
+
token: z.string().optional()
|
|
392
|
+
}).optional()
|
|
393
|
+
}).optional()
|
|
394
|
+
});
|
|
395
|
+
const globals = {
|
|
396
|
+
MAX_WEI_AMOUNT: 115792089237316195423570985008687907853269984665640564039457584007913129639935n,
|
|
397
|
+
CLUSTER_SIZES: {
|
|
398
|
+
QUAD_CLUSTER: 4,
|
|
399
|
+
SEPT_CLUSTER: 7,
|
|
400
|
+
DECA_CLUSTER: 10,
|
|
401
|
+
TRISKAIDEKA_CLUSTER: 13
|
|
402
|
+
},
|
|
403
|
+
FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE: {
|
|
404
|
+
QUAD_CLUSTER: 80,
|
|
405
|
+
SEPT_CLUSTER: 40,
|
|
406
|
+
DECA_CLUSTER: 30,
|
|
407
|
+
TRISKAIDEKA_CLUSTER: 20
|
|
408
|
+
},
|
|
409
|
+
BLOCKS_PER_DAY: 7160n,
|
|
410
|
+
OPERATORS_PER_PAGE: 50,
|
|
411
|
+
BLOCKS_PER_YEAR: 2613400n,
|
|
412
|
+
DEFAULT_CLUSTER_PERIOD: 730,
|
|
413
|
+
NUMBERS_OF_WEEKS_IN_YEAR: 52.1429,
|
|
414
|
+
MAX_VALIDATORS_COUNT_MULTI_FLOW: 50,
|
|
415
|
+
CLUSTER_VALIDITY_PERIOD_MINIMUM: 30,
|
|
416
|
+
OPERATOR_VALIDATORS_LIMIT_PRESERVE: 5,
|
|
417
|
+
MINIMUM_OPERATOR_FEE_PER_BLOCK: 1000000000n,
|
|
418
|
+
MIN_VALIDATORS_COUNT_PER_BULK_REGISTRATION: 1,
|
|
419
|
+
DEFAULT_ADDRESS_WHITELIST: "0x0000000000000000000000000000000000000000"
|
|
420
|
+
};
|
|
421
|
+
const registerValidatorsByClusterSizeLimits = {
|
|
422
|
+
[globals.CLUSTER_SIZES.QUAD_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.QUAD_CLUSTER,
|
|
423
|
+
[globals.CLUSTER_SIZES.SEPT_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.SEPT_CLUSTER,
|
|
424
|
+
[globals.CLUSTER_SIZES.DECA_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.DECA_CLUSTER,
|
|
425
|
+
[globals.CLUSTER_SIZES.TRISKAIDEKA_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.TRISKAIDEKA_CLUSTER
|
|
426
|
+
};
|
|
427
|
+
export {
|
|
428
|
+
formatBigintInput as A,
|
|
429
|
+
ms as B,
|
|
430
|
+
sortNumbers as C,
|
|
431
|
+
getOperatorIds as D,
|
|
432
|
+
decodeOperatorPublicKey as E,
|
|
433
|
+
tryCatch as F,
|
|
434
|
+
configArgsSchema as G,
|
|
435
|
+
chainIds as H,
|
|
436
|
+
contracts as I,
|
|
437
|
+
graph_endpoints as J,
|
|
438
|
+
KeysharesValidationErrors as K,
|
|
439
|
+
rest_endpoints as L,
|
|
440
|
+
registerValidatorsByClusterSizeLimits as M,
|
|
441
|
+
globals as N,
|
|
442
|
+
hoodi as O,
|
|
443
|
+
chains as P,
|
|
444
|
+
networks as Q,
|
|
445
|
+
_percentageFormatter as _,
|
|
446
|
+
bigintMin as a,
|
|
447
|
+
bigintMax as b,
|
|
448
|
+
bigintRound as c,
|
|
449
|
+
bigintFloor as d,
|
|
450
|
+
bigintAbs as e,
|
|
451
|
+
bigintifyNumbers as f,
|
|
452
|
+
createClusterId as g,
|
|
453
|
+
isClusterId as h,
|
|
454
|
+
isBigIntChanged as i,
|
|
455
|
+
getClusterSnapshot as j,
|
|
456
|
+
createEmptyCluster as k,
|
|
457
|
+
add0x as l,
|
|
458
|
+
isKeySharesItem as m,
|
|
459
|
+
KeysharesValidationErrorsMessages as n,
|
|
460
|
+
KeysharesValidationError as o,
|
|
461
|
+
ensureValidatorsUniqueness as p,
|
|
462
|
+
validateConsistentOperatorPublicKeys as q,
|
|
463
|
+
roundOperatorFee as r,
|
|
464
|
+
stringifyBigints as s,
|
|
465
|
+
ensureNoKeysharesErrors as t,
|
|
466
|
+
numberFormatter as u,
|
|
467
|
+
validateConsistentOperatorIds as v,
|
|
468
|
+
percentageFormatter as w,
|
|
469
|
+
bigintFormatter as x,
|
|
470
|
+
ethFormatter as y,
|
|
471
|
+
formatSSV as z
|
|
472
|
+
};
|