@ssv-labs/ssv-sdk 1.0.1 → 1.0.2

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/main.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as decodeOperatorPublicKey, C as stringifyBigints, E as tryCatch, k as configArgsSchema, H as contracts, I as paid_graph_endpoints, J as graph_endpoints, L as rest_endpoints, D as toSolidityCluster$1, w as isKeySharesItem, M as registerValidatorsByClusterSizeLimits, l as createClusterId, m as createEmptyCluster, A as roundOperatorFee, N as globals, g as bigintMax, o as ensureNoKeysharesErrors, p as ensureValidatorsUniqueness, G as validateConsistentOperatorPublicKeys, F as validateConsistentOperatorIds, B as sortNumbers, K as KeysharesValidationError, a as KeysharesValidationErrors } from "./config-BdEJjnYA.mjs";
1
+ import { n as decodeOperatorPublicKey, C as stringifyBigints, E as tryCatch, k as configArgsSchema, H as contracts, I as paid_graph_endpoints, J as graph_endpoints, L as rest_endpoints, D as toSolidityCluster, w as isKeySharesItem, M as registerValidatorsByClusterSizeLimits, l as createClusterId, m as createEmptyCluster, A as roundOperatorFee, N as globals, g as bigintMax, o as ensureNoKeysharesErrors, p as ensureValidatorsUniqueness, G as validateConsistentOperatorPublicKeys, F as validateConsistentOperatorIds, B as sortNumbers, K as KeysharesValidationError, a as KeysharesValidationErrors } from "./config-BdEJjnYA.mjs";
2
2
  import { O, P, Q, R } from "./config-BdEJjnYA.mjs";
3
3
  import { isUndefined, isEqual } from "lodash-es";
4
4
  import { isAddressEqual, decodeEventLog, encodeFunctionData, encodeAbiParameters, parseAbiParameters, zeroAddress } from "viem";
@@ -10,47 +10,148 @@ var ClusterFeeAssetTypes = /* @__PURE__ */ ((ClusterFeeAssetTypes2) => {
10
10
  ClusterFeeAssetTypes2["SSV"] = "SSV";
11
11
  return ClusterFeeAssetTypes2;
12
12
  })(ClusterFeeAssetTypes || {});
13
- const GetClusterSnapshotDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetClusterSnapshot" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "cluster" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "active" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "balance" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "effectiveBalance" } }] } }] } }] };
14
- const GetClusterDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetCluster" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "cluster" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "owner" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeAsset" } }, { "kind": "Field", "name": { "kind": "Name", "value": "active" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "balance" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "operatorIds" } }, { "kind": "Field", "name": { "kind": "Name", "value": "effectiveBalance" } }] } }] } }] };
15
- const GetClustersDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetClusters" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "clusters" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "owner" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeAsset" } }, { "kind": "Field", "name": { "kind": "Name", "value": "active" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "balance" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "operatorIds" } }, { "kind": "Field", "name": { "kind": "Name", "value": "effectiveBalance" } }] } }] } }] };
16
- const GetOwnerNonceDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetOwnerNonce" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "account" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "nonce" } }] } }] } }] };
13
+ const GetClusterSnapshotDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetClusterSnapshot" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "cluster" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "active" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "balance" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "effectiveBalance" } }] } }] } }] };
14
+ const GetClusterDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetCluster" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "cluster" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "owner" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeAsset" } }, { "kind": "Field", "name": { "kind": "Name", "value": "active" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "balance" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "operatorIds" } }, { "kind": "Field", "name": { "kind": "Name", "value": "effectiveBalance" } }] } }] } }] };
15
+ const GetClustersDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetClusters" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "clusters" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "owner" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeAsset" } }, { "kind": "Field", "name": { "kind": "Name", "value": "active" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "balance" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "operatorIds" } }, { "kind": "Field", "name": { "kind": "Name", "value": "effectiveBalance" } }] } }] } }] };
16
+ const GetOwnerNonceDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetOwnerNonce" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "account" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "nonce" } }] } }] } }] };
17
17
  const GetOwnerNonceByBlockDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetOwnerNonceByBlock" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "block" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "account" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "owner" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "block" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "number" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "block" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "nonce" } }] } }] } }] };
18
- const GetOperatorDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetOperator" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "operator" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "publicKey" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "isPrivate" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelistedContract" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelisted" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] } }] };
19
- const GetOperatorsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetOperators" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "operatorIds" } }, "type": { "kind": "NonNullType", "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "operators" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "id_in" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "operatorIds" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "publicKey" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "isPrivate" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelistedContract" } }, { "kind": "Field", "name": { "kind": "Name", "value": "fee" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelisted" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] } }] };
20
- const GetValidatorsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetValidators" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "ids" } }, "type": { "kind": "NonNullType", "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Bytes" } } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "validators" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "id_in" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "ids" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] };
21
- const GetValidatorDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetValidator" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "validator" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] };
18
+ const GetOperatorDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetOperator" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "operator" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "publicKey" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "isPrivate" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelistedContract" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelisted" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] } }] };
19
+ const GetOperatorsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetOperators" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "operatorIds" } }, "type": { "kind": "NonNullType", "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "operators" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "id_in" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "operatorIds" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "publicKey" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "isPrivate" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelistedContract" } }, { "kind": "Field", "name": { "kind": "Name", "value": "fee" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "whitelisted" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] } }] };
20
+ const GetValidatorsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetValidators" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "ids" } }, "type": { "kind": "NonNullType", "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Bytes" } } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "validators" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "id_in" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "ids" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] };
21
+ const GetValidatorDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetValidator" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "validator" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] };
22
22
  const GetClusterBalanceDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetClusterBalance" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "clusterId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "daoAddress" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "operatorIds" } }, "type": { "kind": "NonNullType", "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "daovalues" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "daoAddress" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "networkFee" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexBlockNumber" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexBlockNumberSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "liquidationThreshold" } }, { "kind": "Field", "name": { "kind": "Name", "value": "liquidationThresholdSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "minimumLiquidationCollateral" } }, { "kind": "Field", "name": { "kind": "Name", "value": "minimumLiquidationCollateralSSV" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "operators" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "id_in" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "operatorIds" } } }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "fee" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeIndexBlockNumber" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeIndexSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feeIndexBlockNumberSSV" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "cluster" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "clusterId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "feeAsset" } }, { "kind": "Field", "name": { "kind": "Name", "value": "validatorCount" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "balance" } }, { "kind": "Field", "name": { "kind": "Name", "value": "effectiveBalance" } }] } }] } }] };
23
- const GetDaoValuesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetDaoValues" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "daoAddress" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "daovalues" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "daoAddress" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "networkFee" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexBlockNumber" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexBlockNumberSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "liquidationThreshold" } }, { "kind": "Field", "name": { "kind": "Name", "value": "liquidationThresholdSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "minimumLiquidationCollateral" } }, { "kind": "Field", "name": { "kind": "Name", "value": "minimumLiquidationCollateralSSV" } }] } }] } }] };
24
- const getOwnerNonce = (client, args) => {
25
- const document = typeof args.block === "number" ? GetOwnerNonceByBlockDocument : GetOwnerNonceDocument;
26
- return client.request(document, args).then((r) => r.account?.nonce ?? "0");
23
+ const GetDaoValuesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetDaoValues" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "daoAddress" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_meta" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "block" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "number" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "daovalues" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "daoAddress" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "networkFee" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndex" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexBlockNumber" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "networkFeeIndexBlockNumberSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "liquidationThreshold" } }, { "kind": "Field", "name": { "kind": "Name", "value": "liquidationThresholdSSV" } }, { "kind": "Field", "name": { "kind": "Name", "value": "minimumLiquidationCollateral" } }, { "kind": "Field", "name": { "kind": "Name", "value": "minimumLiquidationCollateralSSV" } }] } }] } }] };
24
+ const requireSafeNumber = (rawValue, fieldName) => {
25
+ if (rawValue === null || typeof rawValue === "undefined") {
26
+ throw new Error(`Could not resolve ${fieldName}`);
27
+ }
28
+ const value = BigInt(rawValue);
29
+ if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
30
+ throw new Error(`${fieldName} exceeds MAX_SAFE_INTEGER`);
31
+ }
32
+ return Number(value);
27
33
  };
28
- const toSolidityCluster = (client, args) => client.request(GetClusterSnapshotDocument, args).then((res) => res.cluster);
29
- const getClusterSnapshot = (client, args) => toSolidityCluster(client, args);
30
- const getCluster = (client, args) => client.request(GetClusterDocument, args).then((res) => res.cluster);
31
- const getClusters = (client, args) => client.request(GetClustersDocument, args).then((res) => res.clusters);
32
- const getOperator = (client, args) => client.request(GetOperatorDocument, args).then((res) => {
33
- if (!res.operator) return null;
34
- return {
35
- ...res.operator,
36
- publicKey: decodeOperatorPublicKey(res.operator.publicKey),
37
- whitelisted: res.operator.whitelisted.map((v) => v.id)
38
- };
34
+ const getSnapshotBlockNumber = (response) => {
35
+ if (response._meta?.block.number === null || typeof response._meta?.block.number === "undefined") {
36
+ throw new Error(
37
+ "Subgraph endpoint must support _meta.block.number for snapshot-aware SDK reads."
38
+ );
39
+ }
40
+ return requireSafeNumber(response._meta.block.number, "snapshot block number");
41
+ };
42
+ const mapOperator = (operator) => ({
43
+ ...operator,
44
+ publicKey: decodeOperatorPublicKey(operator.publicKey),
45
+ whitelisted: operator.whitelisted.map((v) => v.id)
46
+ });
47
+ const withSnapshotBlock = (response, payload) => ({
48
+ blockNumber: getSnapshotBlockNumber(response),
49
+ ...payload
39
50
  });
40
- const getOperators = (client, args) => client.request(GetOperatorsDocument, args).then(
41
- (res) => res.operators.map((o) => ({
42
- ...o,
43
- publicKey: decodeOperatorPublicKey(o.publicKey),
44
- whitelisted: o.whitelisted.map((v) => v.id)
45
- }))
46
- );
47
- const getValidators = (client, args) => client.request(GetValidatorsDocument, args).then((res) => res.validators);
48
- const getValidator = (client, args) => client.request(GetValidatorDocument, args).then((res) => res.validator);
49
- const getClusterBalance$1 = (client, args) => client.request(GetClusterBalanceDocument, args);
50
- const getDaoValues = (client, args) => client.request(GetDaoValuesDocument, args).then((res) => res.daovalues);
51
+ const getOwnerNonce = async (client, args) => {
52
+ if (typeof args.block === "number") {
53
+ const response2 = await client.request(
54
+ GetOwnerNonceByBlockDocument,
55
+ args
56
+ );
57
+ return {
58
+ blockNumber: requireSafeNumber(args.block, "snapshot block number"),
59
+ nonce: requireSafeNumber(response2.account?.nonce ?? "0", "owner nonce")
60
+ };
61
+ }
62
+ const response = await client.request(
63
+ GetOwnerNonceDocument,
64
+ args
65
+ );
66
+ return withSnapshotBlock(response, {
67
+ nonce: requireSafeNumber(response.account?.nonce ?? "0", "owner nonce")
68
+ });
69
+ };
70
+ const getClusterSnapshot = async (client, args) => {
71
+ const response = await client.request(
72
+ GetClusterSnapshotDocument,
73
+ args
74
+ );
75
+ return withSnapshotBlock(response, {
76
+ cluster: response.cluster
77
+ });
78
+ };
79
+ const getCluster = async (client, args) => {
80
+ const response = await client.request(
81
+ GetClusterDocument,
82
+ args
83
+ );
84
+ return withSnapshotBlock(response, {
85
+ cluster: response.cluster
86
+ });
87
+ };
88
+ const getClusters = async (client, args) => {
89
+ const response = await client.request(
90
+ GetClustersDocument,
91
+ args
92
+ );
93
+ return withSnapshotBlock(response, {
94
+ clusters: response.clusters
95
+ });
96
+ };
97
+ const getOperator = async (client, args) => {
98
+ const response = await client.request(
99
+ GetOperatorDocument,
100
+ args
101
+ );
102
+ return withSnapshotBlock(response, {
103
+ operator: response.operator ? mapOperator(response.operator) : null
104
+ });
105
+ };
106
+ const getOperators = async (client, args) => {
107
+ const response = await client.request(
108
+ GetOperatorsDocument,
109
+ args
110
+ );
111
+ return withSnapshotBlock(response, {
112
+ operators: response.operators.map(mapOperator)
113
+ });
114
+ };
115
+ const getValidators = async (client, args) => {
116
+ const response = await client.request(
117
+ GetValidatorsDocument,
118
+ args
119
+ );
120
+ return withSnapshotBlock(response, {
121
+ validators: response.validators
122
+ });
123
+ };
124
+ const getValidator = async (client, args) => {
125
+ const response = await client.request(
126
+ GetValidatorDocument,
127
+ args
128
+ );
129
+ return withSnapshotBlock(response, {
130
+ validator: response.validator
131
+ });
132
+ };
133
+ const getClusterBalance$1 = async (client, args) => {
134
+ const response = await client.request(
135
+ GetClusterBalanceDocument,
136
+ args
137
+ );
138
+ return withSnapshotBlock(response, {
139
+ cluster: response.cluster,
140
+ daovalues: response.daovalues,
141
+ operators: response.operators
142
+ });
143
+ };
144
+ const getDaoValues = async (client, args) => {
145
+ const response = await client.request(
146
+ GetDaoValuesDocument,
147
+ args
148
+ );
149
+ return withSnapshotBlock(response, {
150
+ daovalues: response.daovalues
151
+ });
152
+ };
51
153
  const getQueries = (client) => ({
52
154
  getOwnerNonce: getOwnerNonce.bind(null, client),
53
- toSolidityCluster: toSolidityCluster.bind(null, client),
54
155
  getClusterSnapshot: getClusterSnapshot.bind(null, client),
55
156
  getCluster: getCluster.bind(null, client),
56
157
  getClusters: getClusters.bind(null, client),
@@ -5925,11 +6026,11 @@ const createConfig = (props) => {
5925
6026
  };
5926
6027
  };
5927
6028
  const deposit = async (config, { args: { id, amount }, ...writeOptions }) => {
5928
- const cluster = await config.api.getCluster({ id });
6029
+ const { cluster } = await config.api.getCluster({ id });
5929
6030
  if (!cluster) {
5930
6031
  throw new Error("Cluster not found");
5931
6032
  }
5932
- const snapshot = toSolidityCluster$1(cluster);
6033
+ const snapshot = toSolidityCluster(cluster);
5933
6034
  return config.contract.ssv.write.deposit({
5934
6035
  value: amount,
5935
6036
  args: {
@@ -5959,13 +6060,13 @@ const exitValidators = async (config, { args: { publicKeys, operatorIds }, ...wr
5959
6060
  });
5960
6061
  };
5961
6062
  const liquidateCluster = async (config, { args: { id }, ...writeOptions }) => {
5962
- const cluster = await config.api.getCluster({ id });
6063
+ const { cluster } = await config.api.getCluster({ id });
5963
6064
  if (!cluster) {
5964
6065
  throw new Error("Cluster not found");
5965
6066
  }
5966
6067
  return config.contract.ssv.write.liquidate({
5967
6068
  args: {
5968
- cluster: toSolidityCluster$1(cluster),
6069
+ cluster: toSolidityCluster(cluster),
5969
6070
  clusterOwner: cluster.owner.id,
5970
6071
  operatorIds: cluster.operatorIds.map(BigInt)
5971
6072
  },
@@ -5973,7 +6074,7 @@ const liquidateCluster = async (config, { args: { id }, ...writeOptions }) => {
5973
6074
  });
5974
6075
  };
5975
6076
  const liquidateSSV = async (config, { args: { id }, ...writeOptions }) => {
5976
- const cluster = await config.api.getCluster({ id });
6077
+ const { cluster } = await config.api.getCluster({ id });
5977
6078
  if (!cluster) {
5978
6079
  throw new Error("Cluster not found");
5979
6080
  }
@@ -5981,13 +6082,13 @@ const liquidateSSV = async (config, { args: { id }, ...writeOptions }) => {
5981
6082
  args: {
5982
6083
  clusterOwner: cluster.owner.id,
5983
6084
  operatorIds: cluster.operatorIds.map(BigInt),
5984
- cluster: toSolidityCluster$1(cluster)
6085
+ cluster: toSolidityCluster(cluster)
5985
6086
  },
5986
6087
  ...writeOptions
5987
6088
  });
5988
6089
  };
5989
6090
  const migrateClusterToETH = async (config, { args: { id, amount }, ...writeOptions }) => {
5990
- const cluster = await config.api.getCluster({ id });
6091
+ const { cluster } = await config.api.getCluster({ id });
5991
6092
  if (!cluster) {
5992
6093
  throw new Error("Cluster not found");
5993
6094
  }
@@ -5995,20 +6096,20 @@ const migrateClusterToETH = async (config, { args: { id, amount }, ...writeOptio
5995
6096
  value: amount,
5996
6097
  args: {
5997
6098
  operatorIds: cluster.operatorIds.map(BigInt),
5998
- cluster: toSolidityCluster$1(cluster)
6099
+ cluster: toSolidityCluster(cluster)
5999
6100
  },
6000
6101
  ...writeOptions
6001
6102
  });
6002
6103
  };
6003
6104
  const reactivateCluster = async (config, { args: { id, amount }, ...writeOptions }) => {
6004
- const cluster = await config.api.getCluster({ id });
6105
+ const { cluster } = await config.api.getCluster({ id });
6005
6106
  if (!cluster) {
6006
6107
  throw new Error("Cluster not found");
6007
6108
  }
6008
6109
  return config.contract.ssv.write.reactivate({
6009
6110
  value: amount,
6010
6111
  args: {
6011
- cluster: toSolidityCluster$1(cluster),
6112
+ cluster: toSolidityCluster(cluster),
6012
6113
  operatorIds: cluster.operatorIds.map(BigInt)
6013
6114
  },
6014
6115
  ...writeOptions
@@ -6041,10 +6142,10 @@ const registerValidators = async (config, {
6041
6142
  );
6042
6143
  }
6043
6144
  const clusterId = createClusterId(ownerAddress, operatorIds);
6044
- const cluster = await config.api.getCluster({
6145
+ const { cluster } = await config.api.getCluster({
6045
6146
  id: clusterId
6046
6147
  });
6047
- const snapshot = cluster ? toSolidityCluster$1(cluster) : createEmptyCluster();
6148
+ const snapshot = cluster ? toSolidityCluster(cluster) : createEmptyCluster();
6048
6149
  if (shares.length === 1) {
6049
6150
  return config.contract.ssv.write.registerValidator({
6050
6151
  value: depositAmount,
@@ -6092,10 +6193,10 @@ const registerValidatorsRawData = async (config, { args: { keyshares, ownerAddre
6092
6193
  );
6093
6194
  }
6094
6195
  const clusterId = createClusterId(resolvedOwnerAddress, operatorIds);
6095
- const cluster = await config.api.getCluster({
6196
+ const { cluster } = await config.api.getCluster({
6096
6197
  id: clusterId
6097
6198
  });
6098
- const snapshot = cluster ? toSolidityCluster$1(cluster) : createEmptyCluster();
6199
+ const snapshot = cluster ? toSolidityCluster(cluster) : createEmptyCluster();
6099
6200
  if (shares.length === 1) {
6100
6201
  return config.contract.ssv.write.registerValidator.getTransactionData({
6101
6202
  cluster: snapshot,
@@ -6122,10 +6223,11 @@ const validateSharesPostRegistration = async (config, args) => {
6122
6223
  const receipt = await config.publicClient.waitForTransactionReceipt({
6123
6224
  hash: args.txHash
6124
6225
  });
6125
- const ownerNonce = await config.api.getOwnerNonce({
6226
+ const ownerNonceResponse = await config.api.getOwnerNonce({
6126
6227
  owner: ownerAddress,
6127
6228
  block: Number(receipt.blockNumber) - 1
6128
6229
  });
6230
+ const ownerNonce = ownerNonceResponse?.nonce;
6129
6231
  if (isUndefined(ownerNonce)) {
6130
6232
  throw new Error("Could not fetch owner nonce");
6131
6233
  }
@@ -6151,7 +6253,7 @@ const validateSharesPostRegistration = async (config, args) => {
6151
6253
  operatorsCount: e.args.operatorIds.length,
6152
6254
  isAccountExists: false,
6153
6255
  ownerAddress,
6154
- ownerNonce: Number(ownerNonce) + index,
6256
+ ownerNonce: ownerNonce + index,
6155
6257
  shares: e.args.shares,
6156
6258
  validatorPublicKey: e.args.publicKey
6157
6259
  })
@@ -6163,19 +6265,19 @@ const validateSharesPostRegistration = async (config, args) => {
6163
6265
  isValid,
6164
6266
  validations,
6165
6267
  invalids,
6166
- ownerNonceAtBlock: Number(ownerNonce),
6268
+ ownerNonceAtBlock: ownerNonce,
6167
6269
  block: Number(receipt.blockNumber)
6168
6270
  };
6169
6271
  };
6170
6272
  const removeValidators = async (config, { args: { id, publicKeys }, ...writeOptions }) => {
6171
- const cluster = await config.api.getCluster({ id });
6273
+ const { cluster } = await config.api.getCluster({ id });
6172
6274
  if (!cluster) {
6173
6275
  throw new Error("Cluster not found");
6174
6276
  }
6175
6277
  if (publicKeys.length === 1) {
6176
6278
  return config.contract.ssv.write.removeValidator({
6177
6279
  args: {
6178
- cluster: toSolidityCluster$1(cluster),
6280
+ cluster: toSolidityCluster(cluster),
6179
6281
  publicKey: publicKeys[0],
6180
6282
  operatorIds: cluster.operatorIds.map(BigInt)
6181
6283
  },
@@ -6184,7 +6286,7 @@ const removeValidators = async (config, { args: { id, publicKeys }, ...writeOpti
6184
6286
  }
6185
6287
  return config.contract.ssv.write.bulkRemoveValidator({
6186
6288
  args: {
6187
- cluster: toSolidityCluster$1(cluster),
6289
+ cluster: toSolidityCluster(cluster),
6188
6290
  publicKeys,
6189
6291
  operatorIds: cluster.operatorIds.map(BigInt)
6190
6292
  },
@@ -6200,14 +6302,14 @@ const setFeeRecipient = async (config, { args: { recipient }, ...writeOptions })
6200
6302
  });
6201
6303
  };
6202
6304
  const withdraw$1 = async (config, { args: { id, amount }, ...writeOptions }) => {
6203
- const cluster = await config.api.getCluster({ id });
6305
+ const { cluster } = await config.api.getCluster({ id });
6204
6306
  if (!cluster) {
6205
6307
  throw new Error("Cluster not found");
6206
6308
  }
6207
6309
  return config.contract.ssv.write.withdraw({
6208
6310
  args: {
6209
6311
  amount,
6210
- cluster: toSolidityCluster$1(cluster),
6312
+ cluster: toSolidityCluster(cluster),
6211
6313
  operatorIds: cluster.operatorIds.map(BigInt)
6212
6314
  },
6213
6315
  ...writeOptions
@@ -6429,7 +6531,7 @@ const getClusterBalance = async (config, { operatorIds, ownerAddress }) => {
6429
6531
  operatorIds: operatorIds.map(String),
6430
6532
  clusterId: createClusterId(resolvedOwnerAddress, operatorIds)
6431
6533
  });
6432
- if (!query.cluster || !query.daovalues || !query._meta) {
6534
+ if (!query.cluster || !query.daovalues) {
6433
6535
  throw new Error("Could not fetch cluster balance");
6434
6536
  }
6435
6537
  const isSsvCluster = query.cluster.feeAsset === ClusterFeeAssetTypes.SSV;
@@ -6449,13 +6551,13 @@ const getClusterBalance = async (config, { operatorIds, ownerAddress }) => {
6449
6551
  isSsvCluster ? query.daovalues.liquidationThresholdSSV : query.daovalues.liquidationThreshold
6450
6552
  );
6451
6553
  const scallingCoefficient = isSsvCluster ? globals.SSV_DEDUCTED_DIGITS : globals.ETH_DEDUCTED_DIGITS;
6452
- const cumulativeNetworkFee = networkFeeIndex + (BigInt(query._meta.block.number) - networkFeeIndexBlockNumber) * networkFee - BigInt(query.cluster.networkFeeIndex) * scallingCoefficient;
6554
+ const cumulativeNetworkFee = networkFeeIndex + (BigInt(query.blockNumber) - networkFeeIndexBlockNumber) * networkFee - BigInt(query.cluster.networkFeeIndex) * scallingCoefficient;
6453
6555
  const cumulativeOperatorFee = query.operators.reduce(
6454
6556
  (acc, operator) => {
6455
6557
  const fee = isSsvCluster ? operator.feeSSV : operator.fee;
6456
6558
  const feeIndex = isSsvCluster ? operator.feeIndexSSV : operator.feeIndex;
6457
6559
  const feeIndexBlockNumber = isSsvCluster ? operator.feeIndexBlockNumberSSV : operator.feeIndexBlockNumber;
6458
- return acc + BigInt(feeIndex) + (BigInt(query._meta.block.number) - BigInt(feeIndexBlockNumber)) * BigInt(fee);
6560
+ return acc + BigInt(feeIndex) + (BigInt(query.blockNumber) - BigInt(feeIndexBlockNumber)) * BigInt(fee);
6459
6561
  },
6460
6562
  -BigInt(query.cluster.index) * scallingCoefficient
6461
6563
  );
@@ -6474,6 +6576,7 @@ const getClusterBalance = async (config, { operatorIds, ownerAddress }) => {
6474
6576
  const runway = calculatedClusterBalance - LC;
6475
6577
  const operationalRunway = runway / burnRate / globals.BLOCKS_PER_DAY;
6476
6578
  return {
6579
+ blockNumber: query.blockNumber,
6477
6580
  balance: calculatedClusterBalance,
6478
6581
  operationalRunway
6479
6582
  };
@@ -6500,7 +6603,7 @@ const validateSharesPreRegistration = async (config, { keyshares, operatorIds, o
6500
6603
  "ownerAddress is required when walletClient.account.address is not available"
6501
6604
  );
6502
6605
  }
6503
- const operators = await config.api.getOperators({ operatorIds });
6606
+ const { operators } = await config.api.getOperators({ operatorIds });
6504
6607
  if (operators.length !== operatorIds.length) {
6505
6608
  throw new KeysharesValidationError(
6506
6609
  KeysharesValidationErrors.OperatorDoesNotExist
@@ -6525,7 +6628,9 @@ const validateSharesPreRegistration = async (config, { keyshares, operatorIds, o
6525
6628
  }
6526
6629
  const statuses = await Promise.all(
6527
6630
  shares.map((share) => {
6528
- return config.api.getValidator({ id: share.data.publicKey }).then((res) => [share, Boolean(res)]);
6631
+ return config.api.getValidator({ id: share.data.publicKey }).then(
6632
+ ({ validator }) => [share, Boolean(validator)]
6633
+ );
6529
6634
  })
6530
6635
  );
6531
6636
  if (statuses.every(([, isRegistered]) => isRegistered)) {
@@ -6534,9 +6639,11 @@ const validateSharesPreRegistration = async (config, { keyshares, operatorIds, o
6534
6639
  const shouldValidateNonce = shares.every(
6535
6640
  (share) => typeof share.data.ownerNonce === "number"
6536
6641
  );
6537
- const nonce = shouldValidateNonce ? await config.api.getOwnerNonce({ owner: account }).then((nonce2) => {
6538
- if (!nonce2) throw new Error("Failed to get owner nonce");
6539
- return Number(nonce2);
6642
+ const nonce = shouldValidateNonce ? await config.api.getOwnerNonce({ owner: account }).then(({ nonce: nonce2 }) => {
6643
+ if (typeof nonce2 !== "number") {
6644
+ throw new Error("Failed to get owner nonce");
6645
+ }
6646
+ return nonce2;
6540
6647
  }) : null;
6541
6648
  let i = 0;
6542
6649
  const sharesWithStatuses = statuses.reduce(
@@ -6661,8 +6768,128 @@ const getOperatorCapacity = async (config, operatorId) => {
6661
6768
  }),
6662
6769
  config.contract.ssv.read.getValidatorsPerOperatorLimit()
6663
6770
  ]);
6664
- if (!operator) return 0;
6665
- return limit - Number(operator.validatorCount);
6771
+ if (!operator?.operator) return 0;
6772
+ return limit - Number(operator.operator.validatorCount);
6773
+ };
6774
+ const isKeySharesFileShare = (share) => {
6775
+ return !!share && typeof share === "object" && "data" in share && "payload" in share;
6776
+ };
6777
+ const isPayloadOnlyShare = (share) => {
6778
+ return !!share && typeof share === "object" && "sharesData" in share && "publicKey" in share && "operatorIds" in share && !("data" in share) && !("payload" in share);
6779
+ };
6780
+ const toWebappOperatorKey = (operatorKey) => {
6781
+ if (operatorKey.startsWith("LS0tLS1CRUdJTi")) {
6782
+ return operatorKey;
6783
+ }
6784
+ return Buffer.from(operatorKey, "utf-8").toString("base64");
6785
+ };
6786
+ const buildOperatorMap = async (config, shares, providedOperators) => {
6787
+ if (providedOperators) {
6788
+ return new Map(
6789
+ providedOperators.map((operator) => [
6790
+ operator.id,
6791
+ {
6792
+ ...operator,
6793
+ operatorKey: toWebappOperatorKey(operator.operatorKey)
6794
+ }
6795
+ ])
6796
+ );
6797
+ }
6798
+ const payloadShares = shares.filter(isPayloadOnlyShare);
6799
+ if (!payloadShares.length) {
6800
+ return /* @__PURE__ */ new Map();
6801
+ }
6802
+ const uniqueOperatorIds = [
6803
+ ...new Set(payloadShares.flatMap((share) => share.operatorIds))
6804
+ ];
6805
+ const { operators } = await config.api.getOperators({
6806
+ operatorIds: uniqueOperatorIds.map(String)
6807
+ });
6808
+ if (operators.length !== uniqueOperatorIds.length) {
6809
+ throw new Error(
6810
+ "writeKeysharesFile could not fetch all operators required to build the webapp keyshares format."
6811
+ );
6812
+ }
6813
+ return new Map(
6814
+ operators.map((operator) => [
6815
+ Number(operator.id),
6816
+ {
6817
+ id: Number(operator.id),
6818
+ operatorKey: toWebappOperatorKey(operator.publicKey)
6819
+ }
6820
+ ])
6821
+ );
6822
+ };
6823
+ const normalizeKeySharesItem = async (share, index, args, operatorMap) => {
6824
+ if (isKeySharesItem(share)) {
6825
+ return JSON.parse(share.toJson());
6826
+ }
6827
+ if (isKeySharesFileShare(share)) {
6828
+ return share;
6829
+ }
6830
+ if (!isPayloadOnlyShare(share)) {
6831
+ throw new Error(
6832
+ "writeKeysharesFile received an unsupported keyshares shape."
6833
+ );
6834
+ }
6835
+ if (!args.ownerAddress || typeof args.nonce !== "number") {
6836
+ throw new Error(
6837
+ "writeKeysharesFile requires ownerAddress and nonce when shares contain payload-only keyshares."
6838
+ );
6839
+ }
6840
+ const operators = share.operatorIds.map((operatorId) => {
6841
+ const operator = operatorMap.get(operatorId);
6842
+ if (!operator) {
6843
+ throw new Error(
6844
+ `writeKeysharesFile could not resolve operator ${operatorId} for the webapp keyshares format.`
6845
+ );
6846
+ }
6847
+ return operator;
6848
+ });
6849
+ return {
6850
+ data: {
6851
+ ownerAddress: args.ownerAddress,
6852
+ ownerNonce: args.nonce + index,
6853
+ publicKey: share.publicKey,
6854
+ operators
6855
+ },
6856
+ payload: share
6857
+ };
6858
+ };
6859
+ const getParentDirectory = (filePath) => {
6860
+ const normalizedPath = filePath.replace(/\\/g, "/");
6861
+ const lastSeparatorIndex = normalizedPath.lastIndexOf("/");
6862
+ if (lastSeparatorIndex === -1) {
6863
+ return ".";
6864
+ }
6865
+ if (lastSeparatorIndex === 0) {
6866
+ return normalizedPath[0];
6867
+ }
6868
+ return normalizedPath.slice(0, lastSeparatorIndex);
6869
+ };
6870
+ const writeKeysharesFile = async (config, args) => {
6871
+ const { path, shares } = args;
6872
+ if (!shares.length) {
6873
+ throw new Error(
6874
+ "writeKeysharesFile requires at least one keyshares item to write a file."
6875
+ );
6876
+ }
6877
+ const operatorMap = await buildOperatorMap(config, shares, args.operators);
6878
+ const normalizedShares = await Promise.all(
6879
+ shares.map(
6880
+ (share, index) => normalizeKeySharesItem(share, index, args, operatorMap)
6881
+ )
6882
+ );
6883
+ const keySharesFile = {
6884
+ version: "v1.1.0",
6885
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6886
+ shares: normalizedShares
6887
+ };
6888
+ const { mkdir, writeFile } = await import("node:fs/promises");
6889
+ await mkdir(getParentDirectory(path), { recursive: true });
6890
+ await writeFile(path, JSON.stringify(keySharesFile, null, 2), {
6891
+ encoding: "utf-8"
6892
+ });
6666
6893
  };
6667
6894
  const computeDailyAmount = (value, days) => {
6668
6895
  const scale = 10 ** 6;
@@ -6670,17 +6897,17 @@ const computeDailyAmount = (value, days) => {
6670
6897
  return value * scaledDays * BigInt(globals.BLOCKS_PER_DAY) / BigInt(scale);
6671
6898
  };
6672
6899
  const calcDepositFromRunway = async (config, { clusterId, runway }) => {
6673
- const cluster = await config.api.getCluster({ id: clusterId });
6900
+ const { cluster } = await config.api.getCluster({ id: clusterId });
6674
6901
  if (!cluster) {
6675
6902
  throw new Error("Cluster not found");
6676
6903
  }
6677
- const operators = await config.api.getOperators({
6904
+ const { operators } = await config.api.getOperators({
6678
6905
  operatorIds: cluster.operatorIds
6679
6906
  });
6680
6907
  if (!operators) {
6681
6908
  throw new Error("Operators not found");
6682
6909
  }
6683
- const daoValues = await config.api.getDaoValues({
6910
+ const { daovalues: daoValues } = await config.api.getDaoValues({
6684
6911
  daoAddress: config.contractAddresses.setter
6685
6912
  });
6686
6913
  if (!daoValues) {
@@ -6712,6 +6939,10 @@ const calcDepositFromRunway = async (config, { clusterId, runway }) => {
6712
6939
  };
6713
6940
  const createUtils = (config) => ({
6714
6941
  generateKeyShares,
6942
+ writeKeysharesFile: writeKeysharesFile.bind(
6943
+ null,
6944
+ config
6945
+ ),
6715
6946
  validateKeysharesJSON,
6716
6947
  validateSharesPreRegistration: validateSharesPreRegistration.bind(
6717
6948
  null,
@@ -6799,6 +7030,5 @@ export {
6799
7030
  R as networks,
6800
7031
  paid_graph_endpoints,
6801
7032
  registerValidatorsByClusterSizeLimits,
6802
- rest_endpoints,
6803
- toSolidityCluster
7033
+ rest_endpoints
6804
7034
  };