@ssv-labs/ssv-sdk 0.0.4 → 0.0.5

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.
@@ -165,6 +165,7 @@ export declare const chains: {
165
165
  };
166
166
  };
167
167
  export declare const chainIds: (1 | 560048 | 17000)[];
168
+ export declare const networks: ("Hoodi" | "Ethereum" | "Holesky")[];
168
169
  export type SupportedChainsIDs = (typeof chainIds)[number];
169
170
  export declare const graph_endpoints: Record<SupportedChainsIDs, string>;
170
171
  export declare const rest_endpoints: Record<SupportedChainsIDs, string>;
@@ -1,4 +1,166 @@
1
- import { formatUnits, decodeAbiParameters, parseUnits, isAddress } from "viem";
1
+ import { formatUnits, decodeAbiParameters, defineChain as defineChain$1, parseUnits, isAddress } from "viem";
2
+ function getDefaultExportFromCjs(x) {
3
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
+ }
5
+ var browser = { exports: {} };
6
+ var process = browser.exports = {};
7
+ var cachedSetTimeout;
8
+ var cachedClearTimeout;
9
+ function defaultSetTimout() {
10
+ throw new Error("setTimeout has not been defined");
11
+ }
12
+ function defaultClearTimeout() {
13
+ throw new Error("clearTimeout has not been defined");
14
+ }
15
+ (function() {
16
+ try {
17
+ if (typeof setTimeout === "function") {
18
+ cachedSetTimeout = setTimeout;
19
+ } else {
20
+ cachedSetTimeout = defaultSetTimout;
21
+ }
22
+ } catch (e) {
23
+ cachedSetTimeout = defaultSetTimout;
24
+ }
25
+ try {
26
+ if (typeof clearTimeout === "function") {
27
+ cachedClearTimeout = clearTimeout;
28
+ } else {
29
+ cachedClearTimeout = defaultClearTimeout;
30
+ }
31
+ } catch (e) {
32
+ cachedClearTimeout = defaultClearTimeout;
33
+ }
34
+ })();
35
+ function runTimeout(fun) {
36
+ if (cachedSetTimeout === setTimeout) {
37
+ return setTimeout(fun, 0);
38
+ }
39
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
40
+ cachedSetTimeout = setTimeout;
41
+ return setTimeout(fun, 0);
42
+ }
43
+ try {
44
+ return cachedSetTimeout(fun, 0);
45
+ } catch (e) {
46
+ try {
47
+ return cachedSetTimeout.call(null, fun, 0);
48
+ } catch (e2) {
49
+ return cachedSetTimeout.call(this, fun, 0);
50
+ }
51
+ }
52
+ }
53
+ function runClearTimeout(marker) {
54
+ if (cachedClearTimeout === clearTimeout) {
55
+ return clearTimeout(marker);
56
+ }
57
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
58
+ cachedClearTimeout = clearTimeout;
59
+ return clearTimeout(marker);
60
+ }
61
+ try {
62
+ return cachedClearTimeout(marker);
63
+ } catch (e) {
64
+ try {
65
+ return cachedClearTimeout.call(null, marker);
66
+ } catch (e2) {
67
+ return cachedClearTimeout.call(this, marker);
68
+ }
69
+ }
70
+ }
71
+ var queue = [];
72
+ var draining = false;
73
+ var currentQueue;
74
+ var queueIndex = -1;
75
+ function cleanUpNextTick() {
76
+ if (!draining || !currentQueue) {
77
+ return;
78
+ }
79
+ draining = false;
80
+ if (currentQueue.length) {
81
+ queue = currentQueue.concat(queue);
82
+ } else {
83
+ queueIndex = -1;
84
+ }
85
+ if (queue.length) {
86
+ drainQueue();
87
+ }
88
+ }
89
+ function drainQueue() {
90
+ if (draining) {
91
+ return;
92
+ }
93
+ var timeout = runTimeout(cleanUpNextTick);
94
+ draining = true;
95
+ var len = queue.length;
96
+ while (len) {
97
+ currentQueue = queue;
98
+ queue = [];
99
+ while (++queueIndex < len) {
100
+ if (currentQueue) {
101
+ currentQueue[queueIndex].run();
102
+ }
103
+ }
104
+ queueIndex = -1;
105
+ len = queue.length;
106
+ }
107
+ currentQueue = null;
108
+ draining = false;
109
+ runClearTimeout(timeout);
110
+ }
111
+ process.nextTick = function(fun) {
112
+ var args = new Array(arguments.length - 1);
113
+ if (arguments.length > 1) {
114
+ for (var i = 1; i < arguments.length; i++) {
115
+ args[i - 1] = arguments[i];
116
+ }
117
+ }
118
+ queue.push(new Item(fun, args));
119
+ if (queue.length === 1 && !draining) {
120
+ runTimeout(drainQueue);
121
+ }
122
+ };
123
+ function Item(fun, array) {
124
+ this.fun = fun;
125
+ this.array = array;
126
+ }
127
+ Item.prototype.run = function() {
128
+ this.fun.apply(null, this.array);
129
+ };
130
+ process.title = "browser";
131
+ process.browser = true;
132
+ process.env = {};
133
+ process.argv = [];
134
+ process.version = "";
135
+ process.versions = {};
136
+ function noop() {
137
+ }
138
+ process.on = noop;
139
+ process.addListener = noop;
140
+ process.once = noop;
141
+ process.off = noop;
142
+ process.removeListener = noop;
143
+ process.removeAllListeners = noop;
144
+ process.emit = noop;
145
+ process.prependListener = noop;
146
+ process.prependOnceListener = noop;
147
+ process.listeners = function(name) {
148
+ return [];
149
+ };
150
+ process.binding = function(name) {
151
+ throw new Error("process.binding is not supported");
152
+ };
153
+ process.cwd = function() {
154
+ return "/";
155
+ };
156
+ process.chdir = function(dir) {
157
+ throw new Error("process.chdir is not supported");
158
+ };
159
+ process.umask = function() {
160
+ return 0;
161
+ };
162
+ var browserExports = browser.exports;
163
+ const process$1 = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
2
164
  const numberFormatter = new Intl.NumberFormat("en-US", {
3
165
  useGrouping: true,
4
166
  maximumFractionDigits: 2
@@ -44,6 +206,125 @@ const getOperatorIds = (operators) => {
44
206
  const decodeOperatorPublicKey = (publicKey) => {
45
207
  return decodeAbiParameters([{ type: "string" }], publicKey)[0];
46
208
  };
209
+ function defineChain(chain) {
210
+ return {
211
+ formatters: void 0,
212
+ fees: void 0,
213
+ serializers: void 0,
214
+ ...chain
215
+ };
216
+ }
217
+ const holesky = /* @__PURE__ */ defineChain({
218
+ id: 17e3,
219
+ name: "Holesky",
220
+ nativeCurrency: { name: "Holesky Ether", symbol: "ETH", decimals: 18 },
221
+ rpcUrls: {
222
+ default: {
223
+ http: ["https://ethereum-holesky-rpc.publicnode.com"]
224
+ }
225
+ },
226
+ blockExplorers: {
227
+ default: {
228
+ name: "Etherscan",
229
+ url: "https://holesky.etherscan.io",
230
+ apiUrl: "https://api-holesky.etherscan.io/api"
231
+ }
232
+ },
233
+ contracts: {
234
+ multicall3: {
235
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
236
+ blockCreated: 77
237
+ },
238
+ ensRegistry: {
239
+ address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
240
+ blockCreated: 801613
241
+ },
242
+ ensUniversalResolver: {
243
+ address: "0xa6AC935D4971E3CD133b950aE053bECD16fE7f3b",
244
+ blockCreated: 973484
245
+ }
246
+ },
247
+ testnet: true
248
+ });
249
+ const mainnet = /* @__PURE__ */ defineChain({
250
+ id: 1,
251
+ name: "Ethereum",
252
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
253
+ rpcUrls: {
254
+ default: {
255
+ http: ["https://cloudflare-eth.com"]
256
+ }
257
+ },
258
+ blockExplorers: {
259
+ default: {
260
+ name: "Etherscan",
261
+ url: "https://etherscan.io",
262
+ apiUrl: "https://api.etherscan.io/api"
263
+ }
264
+ },
265
+ contracts: {
266
+ ensRegistry: {
267
+ address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
268
+ },
269
+ ensUniversalResolver: {
270
+ address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67",
271
+ blockCreated: 19258213
272
+ },
273
+ multicall3: {
274
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
275
+ blockCreated: 14353601
276
+ }
277
+ }
278
+ });
279
+ const hoodi = defineChain$1({
280
+ id: 560048,
281
+ name: "Hoodi",
282
+ rpcUrls: {
283
+ default: {
284
+ http: ["https://rpc.hoodi.ethpandaops.io"]
285
+ }
286
+ },
287
+ nativeCurrency: {
288
+ name: "Hoodi Ether",
289
+ symbol: "ETH",
290
+ decimals: 18
291
+ },
292
+ testnet: true
293
+ });
294
+ const chains = {
295
+ mainnet,
296
+ holesky,
297
+ hoodi
298
+ };
299
+ const chainIds = Object.values(chains).map((chain) => chain.id);
300
+ const networks = Object.values(chains).map((chain) => chain.name);
301
+ const graph_endpoints = {
302
+ [mainnet.id]: "https://api.studio.thegraph.com/query/71118/ssv-network-ethereum/version/latest",
303
+ [holesky.id]: "https://api.studio.thegraph.com/query/71118/ssv-network-holesky/version/latest",
304
+ [hoodi.id]: "https://graph-node-hoodi.stage.ops.ssvlabsinternal.com/subgraphs/name/ssv-bapps-hoodi"
305
+ };
306
+ const rest_endpoints = {
307
+ [mainnet.id]: "https://api.ssv.network/api/v4/mainnet",
308
+ [holesky.id]: "https://api.ssv.network/api/v4/holesky",
309
+ [hoodi.id]: "https://api.ssv.network/api/v4/hoodi"
310
+ };
311
+ const contracts = {
312
+ [mainnet.id]: {
313
+ setter: "0xDD9BC35aE942eF0cFa76930954a156B3fF30a4E1",
314
+ getter: "0xafE830B6Ee262ba11cce5F32fDCd760FFE6a66e4",
315
+ token: "0x9D65fF81a3c488d585bBfb0Bfe3c7707c7917f54"
316
+ },
317
+ [holesky.id]: {
318
+ setter: "0x38A4794cCEd47d3baf7370CcC43B560D3a1beEFA",
319
+ getter: "0x352A18AEe90cdcd825d1E37d9939dCA86C00e281",
320
+ token: "0xad45A78180961079BFaeEe349704F411dfF947C6"
321
+ },
322
+ [hoodi.id]: {
323
+ setter: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c",
324
+ getter: "0x5AdDb3f1529C5ec70D77400499eE4bbF328368fe",
325
+ token: "0x9F5d4Ec84fC4785788aB44F9de973cF34F7A038e"
326
+ }
327
+ };
47
328
  const global = globalThis || void 0 || self;
48
329
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
49
330
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
@@ -5107,32 +5388,131 @@ var z = /* @__PURE__ */ Object.freeze({
5107
5388
  ZodError
5108
5389
  });
5109
5390
  const configArgsSchema = z.object({
5110
- walletClient: z.custom((val) => typeof val === "object" && val !== null, {}),
5111
- publicClient: z.custom((val) => typeof val === "object" && val !== null, {})
5391
+ publicClient: z.custom().superRefine((val, ctx) => {
5392
+ const client = val;
5393
+ if (!client) {
5394
+ ctx.addIssue({
5395
+ code: z.ZodIssueCode.custom,
5396
+ message: "Public client must be provided"
5397
+ });
5398
+ return false;
5399
+ }
5400
+ if (client.chain === void 0) {
5401
+ ctx.addIssue({
5402
+ code: z.ZodIssueCode.custom,
5403
+ message: "Public client must have a chain property"
5404
+ });
5405
+ return false;
5406
+ }
5407
+ if (!chainIds.includes(client.chain?.id)) {
5408
+ ctx.addIssue({
5409
+ code: z.ZodIssueCode.custom,
5410
+ message: `Public client chain must be one of [${networks.join(", ")}]`
5411
+ });
5412
+ return false;
5413
+ }
5414
+ return true;
5415
+ }),
5416
+ walletClient: z.custom().superRefine((val, ctx) => {
5417
+ const client = val;
5418
+ if (!client) {
5419
+ ctx.addIssue({
5420
+ code: z.ZodIssueCode.custom,
5421
+ message: "Wallet client must be provided"
5422
+ });
5423
+ return false;
5424
+ }
5425
+ if (client.chain === void 0) {
5426
+ ctx.addIssue({
5427
+ code: z.ZodIssueCode.custom,
5428
+ message: "Wallet client must have a chain property"
5429
+ });
5430
+ return false;
5431
+ }
5432
+ if (!chainIds.includes(client.chain?.id)) {
5433
+ ctx.addIssue({
5434
+ code: z.ZodIssueCode.custom,
5435
+ message: `Wallet client chain must be one of [${networks.join(", ")}]`
5436
+ });
5437
+ return false;
5438
+ }
5439
+ return true;
5440
+ }),
5441
+ _: z.object({
5442
+ graphUrl: z.string().url().optional(),
5443
+ restUrl: z.string().url().optional(),
5444
+ contractAddresses: z.object({
5445
+ setter: z.string().optional(),
5446
+ getter: z.string().optional(),
5447
+ token: z.string().optional()
5448
+ }).optional()
5449
+ }).optional()
5112
5450
  });
5451
+ const globals = {
5452
+ MAX_WEI_AMOUNT: 115792089237316195423570985008687907853269984665640564039457584007913129639935n,
5453
+ CLUSTER_SIZES: {
5454
+ QUAD_CLUSTER: 4,
5455
+ SEPT_CLUSTER: 7,
5456
+ DECA_CLUSTER: 10,
5457
+ TRISKAIDEKA_CLUSTER: 13
5458
+ },
5459
+ FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE: {
5460
+ QUAD_CLUSTER: 80,
5461
+ SEPT_CLUSTER: 40,
5462
+ DECA_CLUSTER: 30,
5463
+ TRISKAIDEKA_CLUSTER: 20
5464
+ },
5465
+ BLOCKS_PER_DAY: 7160n,
5466
+ OPERATORS_PER_PAGE: 50,
5467
+ BLOCKS_PER_YEAR: 2613400n,
5468
+ DEFAULT_CLUSTER_PERIOD: 730,
5469
+ NUMBERS_OF_WEEKS_IN_YEAR: 52.1429,
5470
+ MAX_VALIDATORS_COUNT_MULTI_FLOW: 50,
5471
+ CLUSTER_VALIDITY_PERIOD_MINIMUM: 30,
5472
+ OPERATOR_VALIDATORS_LIMIT_PRESERVE: 5,
5473
+ MINIMUM_OPERATOR_FEE_PER_BLOCK: 1000000000n,
5474
+ MIN_VALIDATORS_COUNT_PER_BULK_REGISTRATION: 1,
5475
+ DEFAULT_ADDRESS_WHITELIST: "0x0000000000000000000000000000000000000000"
5476
+ };
5477
+ const registerValidatorsByClusterSizeLimits = {
5478
+ [globals.CLUSTER_SIZES.QUAD_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.QUAD_CLUSTER,
5479
+ [globals.CLUSTER_SIZES.SEPT_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.SEPT_CLUSTER,
5480
+ [globals.CLUSTER_SIZES.DECA_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.DECA_CLUSTER,
5481
+ [globals.CLUSTER_SIZES.TRISKAIDEKA_CLUSTER]: globals.FIXED_VALIDATORS_COUNT_PER_CLUSTER_SIZE.TRISKAIDEKA_CLUSTER
5482
+ };
5113
5483
  export {
5114
- bigintRound as A,
5115
- bigintFloor as B,
5116
- bigintAbs as C,
5117
- isBigIntChanged as D,
5118
- bigintifyNumbers as E,
5119
- isClusterId as F,
5120
- add0x as G,
5121
- KeysharesValidationErrorsMessages as H,
5122
- numberFormatter as I,
5123
- percentageFormatter as J,
5484
+ formatSSV as $,
5485
+ ensureNoKeysharesErrors as A,
5486
+ ensureValidatorsUniqueness as B,
5487
+ validateConsistentOperatorPublicKeys as C,
5488
+ validateConsistentOperatorIds as D,
5489
+ sortNumbers as E,
5490
+ KeysharesValidationErrors as F,
5491
+ hoodi as G,
5492
+ chains as H,
5493
+ networks as I,
5494
+ bigintMin as J,
5124
5495
  KeysharesValidationError as K,
5125
- bigintFormatter as L,
5496
+ bigintRound as L,
5126
5497
  MapCache as M,
5127
- ethFormatter as N,
5128
- formatSSV as O,
5129
- formatBigintInput as P,
5130
- ms as Q,
5131
- getOperatorIds as R,
5498
+ bigintFloor as N,
5499
+ bigintAbs as O,
5500
+ isBigIntChanged as P,
5501
+ bigintifyNumbers as Q,
5502
+ isClusterId as R,
5132
5503
  Symbol$1 as S,
5504
+ add0x as T,
5133
5505
  Uint8Array as U,
5506
+ KeysharesValidationErrorsMessages as V,
5507
+ numberFormatter as W,
5508
+ percentageFormatter as X,
5509
+ bigintFormatter as Y,
5510
+ ethFormatter as Z,
5134
5511
  _percentageFormatter as _,
5135
5512
  getTag as a,
5513
+ formatBigintInput as a0,
5514
+ ms as a1,
5515
+ getOperatorIds as a2,
5136
5516
  Stack as b,
5137
5517
  isTypedArray as c,
5138
5518
  decodeOperatorPublicKey as d,
@@ -5143,19 +5523,19 @@ export {
5143
5523
  isBuffer as i,
5144
5524
  isUndefined as j,
5145
5525
  configArgsSchema as k,
5146
- getClusterSnapshot as l,
5147
- isKeySharesItem as m,
5148
- createClusterId as n,
5149
- createEmptyCluster as o,
5150
- bigintMax as p,
5151
- ensureNoKeysharesErrors as q,
5152
- roundOperatorFee as r,
5526
+ chainIds as l,
5527
+ contracts as m,
5528
+ graph_endpoints as n,
5529
+ getClusterSnapshot as o,
5530
+ process$1 as p,
5531
+ isKeySharesItem as q,
5532
+ rest_endpoints as r,
5153
5533
  stringifyBigints as s,
5154
5534
  tryCatch as t,
5155
- ensureValidatorsUniqueness as u,
5156
- validateConsistentOperatorPublicKeys as v,
5157
- validateConsistentOperatorIds as w,
5158
- sortNumbers as x,
5159
- KeysharesValidationErrors as y,
5160
- bigintMin as z
5535
+ registerValidatorsByClusterSizeLimits as u,
5536
+ createClusterId as v,
5537
+ createEmptyCluster as w,
5538
+ roundOperatorFee as x,
5539
+ globals as y,
5540
+ bigintMax as z
5161
5541
  };