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