@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/README.md +22 -6
- package/dist/api/subgraph/index.d.ts +49 -82
- package/dist/graphql/graphql.d.ts +137 -0
- package/dist/libs/api/index.d.ts +0 -1
- package/dist/libs/operator/methods.d.ts +1 -1
- package/dist/libs/utils/index.d.ts +2 -0
- package/dist/libs/utils/methods/get-cluster-balance.d.ts +1 -0
- package/dist/libs/utils/methods/index.d.ts +1 -0
- package/dist/libs/utils/methods/write-keyshares-file.d.ts +16 -0
- package/dist/main.js +313 -61
- package/dist/main.mjs +303 -73
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
2
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
25
|
const config = require("./config-ClGS9Tic.js");
|
|
4
26
|
const lodashEs = require("lodash-es");
|
|
@@ -10,47 +32,148 @@ var ClusterFeeAssetTypes = /* @__PURE__ */ ((ClusterFeeAssetTypes2) => {
|
|
|
10
32
|
ClusterFeeAssetTypes2["SSV"] = "SSV";
|
|
11
33
|
return ClusterFeeAssetTypes2;
|
|
12
34
|
})(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" } }] } }] } }] };
|
|
35
|
+
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" } }] } }] } }] };
|
|
36
|
+
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" } }] } }] } }] };
|
|
37
|
+
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" } }] } }] } }] };
|
|
38
|
+
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
39
|
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" } }] } }] } }] };
|
|
40
|
+
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" } }] } }] } }] } }] };
|
|
41
|
+
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" } }] } }] } }] } }] };
|
|
42
|
+
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" } }] } }] } }] };
|
|
43
|
+
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
44
|
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
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
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" } }] } }] } }] };
|
|
46
|
+
const requireSafeNumber = (rawValue, fieldName) => {
|
|
47
|
+
if (rawValue === null || typeof rawValue === "undefined") {
|
|
48
|
+
throw new Error(`Could not resolve ${fieldName}`);
|
|
49
|
+
}
|
|
50
|
+
const value = BigInt(rawValue);
|
|
51
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
52
|
+
throw new Error(`${fieldName} exceeds MAX_SAFE_INTEGER`);
|
|
53
|
+
}
|
|
54
|
+
return Number(value);
|
|
27
55
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
const getSnapshotBlockNumber = (response) => {
|
|
57
|
+
if (response._meta?.block.number === null || typeof response._meta?.block.number === "undefined") {
|
|
58
|
+
throw new Error(
|
|
59
|
+
"Subgraph endpoint must support _meta.block.number for snapshot-aware SDK reads."
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return requireSafeNumber(response._meta.block.number, "snapshot block number");
|
|
63
|
+
};
|
|
64
|
+
const mapOperator = (operator) => ({
|
|
65
|
+
...operator,
|
|
66
|
+
publicKey: config.decodeOperatorPublicKey(operator.publicKey),
|
|
67
|
+
whitelisted: operator.whitelisted.map((v) => v.id)
|
|
68
|
+
});
|
|
69
|
+
const withSnapshotBlock = (response, payload) => ({
|
|
70
|
+
blockNumber: getSnapshotBlockNumber(response),
|
|
71
|
+
...payload
|
|
39
72
|
});
|
|
40
|
-
const
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
73
|
+
const getOwnerNonce = async (client, args) => {
|
|
74
|
+
if (typeof args.block === "number") {
|
|
75
|
+
const response2 = await client.request(
|
|
76
|
+
GetOwnerNonceByBlockDocument,
|
|
77
|
+
args
|
|
78
|
+
);
|
|
79
|
+
return {
|
|
80
|
+
blockNumber: requireSafeNumber(args.block, "snapshot block number"),
|
|
81
|
+
nonce: requireSafeNumber(response2.account?.nonce ?? "0", "owner nonce")
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const response = await client.request(
|
|
85
|
+
GetOwnerNonceDocument,
|
|
86
|
+
args
|
|
87
|
+
);
|
|
88
|
+
return withSnapshotBlock(response, {
|
|
89
|
+
nonce: requireSafeNumber(response.account?.nonce ?? "0", "owner nonce")
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const getClusterSnapshot = async (client, args) => {
|
|
93
|
+
const response = await client.request(
|
|
94
|
+
GetClusterSnapshotDocument,
|
|
95
|
+
args
|
|
96
|
+
);
|
|
97
|
+
return withSnapshotBlock(response, {
|
|
98
|
+
cluster: response.cluster
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const getCluster = async (client, args) => {
|
|
102
|
+
const response = await client.request(
|
|
103
|
+
GetClusterDocument,
|
|
104
|
+
args
|
|
105
|
+
);
|
|
106
|
+
return withSnapshotBlock(response, {
|
|
107
|
+
cluster: response.cluster
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const getClusters = async (client, args) => {
|
|
111
|
+
const response = await client.request(
|
|
112
|
+
GetClustersDocument,
|
|
113
|
+
args
|
|
114
|
+
);
|
|
115
|
+
return withSnapshotBlock(response, {
|
|
116
|
+
clusters: response.clusters
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const getOperator = async (client, args) => {
|
|
120
|
+
const response = await client.request(
|
|
121
|
+
GetOperatorDocument,
|
|
122
|
+
args
|
|
123
|
+
);
|
|
124
|
+
return withSnapshotBlock(response, {
|
|
125
|
+
operator: response.operator ? mapOperator(response.operator) : null
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const getOperators = async (client, args) => {
|
|
129
|
+
const response = await client.request(
|
|
130
|
+
GetOperatorsDocument,
|
|
131
|
+
args
|
|
132
|
+
);
|
|
133
|
+
return withSnapshotBlock(response, {
|
|
134
|
+
operators: response.operators.map(mapOperator)
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const getValidators = async (client, args) => {
|
|
138
|
+
const response = await client.request(
|
|
139
|
+
GetValidatorsDocument,
|
|
140
|
+
args
|
|
141
|
+
);
|
|
142
|
+
return withSnapshotBlock(response, {
|
|
143
|
+
validators: response.validators
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const getValidator = async (client, args) => {
|
|
147
|
+
const response = await client.request(
|
|
148
|
+
GetValidatorDocument,
|
|
149
|
+
args
|
|
150
|
+
);
|
|
151
|
+
return withSnapshotBlock(response, {
|
|
152
|
+
validator: response.validator
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const getClusterBalance$1 = async (client, args) => {
|
|
156
|
+
const response = await client.request(
|
|
157
|
+
GetClusterBalanceDocument,
|
|
158
|
+
args
|
|
159
|
+
);
|
|
160
|
+
return withSnapshotBlock(response, {
|
|
161
|
+
cluster: response.cluster,
|
|
162
|
+
daovalues: response.daovalues,
|
|
163
|
+
operators: response.operators
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
const getDaoValues = async (client, args) => {
|
|
167
|
+
const response = await client.request(
|
|
168
|
+
GetDaoValuesDocument,
|
|
169
|
+
args
|
|
170
|
+
);
|
|
171
|
+
return withSnapshotBlock(response, {
|
|
172
|
+
daovalues: response.daovalues
|
|
173
|
+
});
|
|
174
|
+
};
|
|
51
175
|
const getQueries = (client) => ({
|
|
52
176
|
getOwnerNonce: getOwnerNonce.bind(null, client),
|
|
53
|
-
toSolidityCluster: toSolidityCluster.bind(null, client),
|
|
54
177
|
getClusterSnapshot: getClusterSnapshot.bind(null, client),
|
|
55
178
|
getCluster: getCluster.bind(null, client),
|
|
56
179
|
getClusters: getClusters.bind(null, client),
|
|
@@ -5925,7 +6048,7 @@ const createConfig = (props) => {
|
|
|
5925
6048
|
};
|
|
5926
6049
|
};
|
|
5927
6050
|
const deposit = async (config$1, { args: { id, amount }, ...writeOptions }) => {
|
|
5928
|
-
const cluster = await config$1.api.getCluster({ id });
|
|
6051
|
+
const { cluster } = await config$1.api.getCluster({ id });
|
|
5929
6052
|
if (!cluster) {
|
|
5930
6053
|
throw new Error("Cluster not found");
|
|
5931
6054
|
}
|
|
@@ -5959,7 +6082,7 @@ const exitValidators = async (config2, { args: { publicKeys, operatorIds }, ...w
|
|
|
5959
6082
|
});
|
|
5960
6083
|
};
|
|
5961
6084
|
const liquidateCluster = async (config$1, { args: { id }, ...writeOptions }) => {
|
|
5962
|
-
const cluster = await config$1.api.getCluster({ id });
|
|
6085
|
+
const { cluster } = await config$1.api.getCluster({ id });
|
|
5963
6086
|
if (!cluster) {
|
|
5964
6087
|
throw new Error("Cluster not found");
|
|
5965
6088
|
}
|
|
@@ -5973,7 +6096,7 @@ const liquidateCluster = async (config$1, { args: { id }, ...writeOptions }) =>
|
|
|
5973
6096
|
});
|
|
5974
6097
|
};
|
|
5975
6098
|
const liquidateSSV = async (config$1, { args: { id }, ...writeOptions }) => {
|
|
5976
|
-
const cluster = await config$1.api.getCluster({ id });
|
|
6099
|
+
const { cluster } = await config$1.api.getCluster({ id });
|
|
5977
6100
|
if (!cluster) {
|
|
5978
6101
|
throw new Error("Cluster not found");
|
|
5979
6102
|
}
|
|
@@ -5987,7 +6110,7 @@ const liquidateSSV = async (config$1, { args: { id }, ...writeOptions }) => {
|
|
|
5987
6110
|
});
|
|
5988
6111
|
};
|
|
5989
6112
|
const migrateClusterToETH = async (config$1, { args: { id, amount }, ...writeOptions }) => {
|
|
5990
|
-
const cluster = await config$1.api.getCluster({ id });
|
|
6113
|
+
const { cluster } = await config$1.api.getCluster({ id });
|
|
5991
6114
|
if (!cluster) {
|
|
5992
6115
|
throw new Error("Cluster not found");
|
|
5993
6116
|
}
|
|
@@ -6001,7 +6124,7 @@ const migrateClusterToETH = async (config$1, { args: { id, amount }, ...writeOpt
|
|
|
6001
6124
|
});
|
|
6002
6125
|
};
|
|
6003
6126
|
const reactivateCluster = async (config$1, { args: { id, amount }, ...writeOptions }) => {
|
|
6004
|
-
const cluster = await config$1.api.getCluster({ id });
|
|
6127
|
+
const { cluster } = await config$1.api.getCluster({ id });
|
|
6005
6128
|
if (!cluster) {
|
|
6006
6129
|
throw new Error("Cluster not found");
|
|
6007
6130
|
}
|
|
@@ -6041,7 +6164,7 @@ const registerValidators = async (config$1, {
|
|
|
6041
6164
|
);
|
|
6042
6165
|
}
|
|
6043
6166
|
const clusterId = config.createClusterId(ownerAddress, operatorIds);
|
|
6044
|
-
const cluster = await config$1.api.getCluster({
|
|
6167
|
+
const { cluster } = await config$1.api.getCluster({
|
|
6045
6168
|
id: clusterId
|
|
6046
6169
|
});
|
|
6047
6170
|
const snapshot = cluster ? config.toSolidityCluster(cluster) : config.createEmptyCluster();
|
|
@@ -6092,7 +6215,7 @@ const registerValidatorsRawData = async (config$1, { args: { keyshares, ownerAdd
|
|
|
6092
6215
|
);
|
|
6093
6216
|
}
|
|
6094
6217
|
const clusterId = config.createClusterId(resolvedOwnerAddress, operatorIds);
|
|
6095
|
-
const cluster = await config$1.api.getCluster({
|
|
6218
|
+
const { cluster } = await config$1.api.getCluster({
|
|
6096
6219
|
id: clusterId
|
|
6097
6220
|
});
|
|
6098
6221
|
const snapshot = cluster ? config.toSolidityCluster(cluster) : config.createEmptyCluster();
|
|
@@ -6122,10 +6245,11 @@ const validateSharesPostRegistration = async (config2, args) => {
|
|
|
6122
6245
|
const receipt = await config2.publicClient.waitForTransactionReceipt({
|
|
6123
6246
|
hash: args.txHash
|
|
6124
6247
|
});
|
|
6125
|
-
const
|
|
6248
|
+
const ownerNonceResponse = await config2.api.getOwnerNonce({
|
|
6126
6249
|
owner: ownerAddress,
|
|
6127
6250
|
block: Number(receipt.blockNumber) - 1
|
|
6128
6251
|
});
|
|
6252
|
+
const ownerNonce = ownerNonceResponse?.nonce;
|
|
6129
6253
|
if (lodashEs.isUndefined(ownerNonce)) {
|
|
6130
6254
|
throw new Error("Could not fetch owner nonce");
|
|
6131
6255
|
}
|
|
@@ -6151,7 +6275,7 @@ const validateSharesPostRegistration = async (config2, args) => {
|
|
|
6151
6275
|
operatorsCount: e.args.operatorIds.length,
|
|
6152
6276
|
isAccountExists: false,
|
|
6153
6277
|
ownerAddress,
|
|
6154
|
-
ownerNonce:
|
|
6278
|
+
ownerNonce: ownerNonce + index,
|
|
6155
6279
|
shares: e.args.shares,
|
|
6156
6280
|
validatorPublicKey: e.args.publicKey
|
|
6157
6281
|
})
|
|
@@ -6163,12 +6287,12 @@ const validateSharesPostRegistration = async (config2, args) => {
|
|
|
6163
6287
|
isValid,
|
|
6164
6288
|
validations,
|
|
6165
6289
|
invalids,
|
|
6166
|
-
ownerNonceAtBlock:
|
|
6290
|
+
ownerNonceAtBlock: ownerNonce,
|
|
6167
6291
|
block: Number(receipt.blockNumber)
|
|
6168
6292
|
};
|
|
6169
6293
|
};
|
|
6170
6294
|
const removeValidators = async (config$1, { args: { id, publicKeys }, ...writeOptions }) => {
|
|
6171
|
-
const cluster = await config$1.api.getCluster({ id });
|
|
6295
|
+
const { cluster } = await config$1.api.getCluster({ id });
|
|
6172
6296
|
if (!cluster) {
|
|
6173
6297
|
throw new Error("Cluster not found");
|
|
6174
6298
|
}
|
|
@@ -6200,7 +6324,7 @@ const setFeeRecipient = async (config2, { args: { recipient }, ...writeOptions }
|
|
|
6200
6324
|
});
|
|
6201
6325
|
};
|
|
6202
6326
|
const withdraw$1 = async (config$1, { args: { id, amount }, ...writeOptions }) => {
|
|
6203
|
-
const cluster = await config$1.api.getCluster({ id });
|
|
6327
|
+
const { cluster } = await config$1.api.getCluster({ id });
|
|
6204
6328
|
if (!cluster) {
|
|
6205
6329
|
throw new Error("Cluster not found");
|
|
6206
6330
|
}
|
|
@@ -6429,7 +6553,7 @@ const getClusterBalance = async (config$1, { operatorIds, ownerAddress }) => {
|
|
|
6429
6553
|
operatorIds: operatorIds.map(String),
|
|
6430
6554
|
clusterId: config.createClusterId(resolvedOwnerAddress, operatorIds)
|
|
6431
6555
|
});
|
|
6432
|
-
if (!query.cluster || !query.daovalues
|
|
6556
|
+
if (!query.cluster || !query.daovalues) {
|
|
6433
6557
|
throw new Error("Could not fetch cluster balance");
|
|
6434
6558
|
}
|
|
6435
6559
|
const isSsvCluster = query.cluster.feeAsset === ClusterFeeAssetTypes.SSV;
|
|
@@ -6449,13 +6573,13 @@ const getClusterBalance = async (config$1, { operatorIds, ownerAddress }) => {
|
|
|
6449
6573
|
isSsvCluster ? query.daovalues.liquidationThresholdSSV : query.daovalues.liquidationThreshold
|
|
6450
6574
|
);
|
|
6451
6575
|
const scallingCoefficient = isSsvCluster ? config.globals.SSV_DEDUCTED_DIGITS : config.globals.ETH_DEDUCTED_DIGITS;
|
|
6452
|
-
const cumulativeNetworkFee = networkFeeIndex + (BigInt(query.
|
|
6576
|
+
const cumulativeNetworkFee = networkFeeIndex + (BigInt(query.blockNumber) - networkFeeIndexBlockNumber) * networkFee - BigInt(query.cluster.networkFeeIndex) * scallingCoefficient;
|
|
6453
6577
|
const cumulativeOperatorFee = query.operators.reduce(
|
|
6454
6578
|
(acc, operator) => {
|
|
6455
6579
|
const fee = isSsvCluster ? operator.feeSSV : operator.fee;
|
|
6456
6580
|
const feeIndex = isSsvCluster ? operator.feeIndexSSV : operator.feeIndex;
|
|
6457
6581
|
const feeIndexBlockNumber = isSsvCluster ? operator.feeIndexBlockNumberSSV : operator.feeIndexBlockNumber;
|
|
6458
|
-
return acc + BigInt(feeIndex) + (BigInt(query.
|
|
6582
|
+
return acc + BigInt(feeIndex) + (BigInt(query.blockNumber) - BigInt(feeIndexBlockNumber)) * BigInt(fee);
|
|
6459
6583
|
},
|
|
6460
6584
|
-BigInt(query.cluster.index) * scallingCoefficient
|
|
6461
6585
|
);
|
|
@@ -6474,6 +6598,7 @@ const getClusterBalance = async (config$1, { operatorIds, ownerAddress }) => {
|
|
|
6474
6598
|
const runway = calculatedClusterBalance - LC;
|
|
6475
6599
|
const operationalRunway = runway / burnRate / config.globals.BLOCKS_PER_DAY;
|
|
6476
6600
|
return {
|
|
6601
|
+
blockNumber: query.blockNumber,
|
|
6477
6602
|
balance: calculatedClusterBalance,
|
|
6478
6603
|
operationalRunway
|
|
6479
6604
|
};
|
|
@@ -6500,7 +6625,7 @@ const validateSharesPreRegistration = async (config$1, { keyshares, operatorIds,
|
|
|
6500
6625
|
"ownerAddress is required when walletClient.account.address is not available"
|
|
6501
6626
|
);
|
|
6502
6627
|
}
|
|
6503
|
-
const operators = await config$1.api.getOperators({ operatorIds });
|
|
6628
|
+
const { operators } = await config$1.api.getOperators({ operatorIds });
|
|
6504
6629
|
if (operators.length !== operatorIds.length) {
|
|
6505
6630
|
throw new config.KeysharesValidationError(
|
|
6506
6631
|
config.KeysharesValidationErrors.OperatorDoesNotExist
|
|
@@ -6525,7 +6650,9 @@ const validateSharesPreRegistration = async (config$1, { keyshares, operatorIds,
|
|
|
6525
6650
|
}
|
|
6526
6651
|
const statuses = await Promise.all(
|
|
6527
6652
|
shares.map((share) => {
|
|
6528
|
-
return config$1.api.getValidator({ id: share.data.publicKey }).then(
|
|
6653
|
+
return config$1.api.getValidator({ id: share.data.publicKey }).then(
|
|
6654
|
+
({ validator }) => [share, Boolean(validator)]
|
|
6655
|
+
);
|
|
6529
6656
|
})
|
|
6530
6657
|
);
|
|
6531
6658
|
if (statuses.every(([, isRegistered]) => isRegistered)) {
|
|
@@ -6534,9 +6661,11 @@ const validateSharesPreRegistration = async (config$1, { keyshares, operatorIds,
|
|
|
6534
6661
|
const shouldValidateNonce = shares.every(
|
|
6535
6662
|
(share) => typeof share.data.ownerNonce === "number"
|
|
6536
6663
|
);
|
|
6537
|
-
const nonce = shouldValidateNonce ? await config$1.api.getOwnerNonce({ owner: account }).then((nonce2) => {
|
|
6538
|
-
if (
|
|
6539
|
-
|
|
6664
|
+
const nonce = shouldValidateNonce ? await config$1.api.getOwnerNonce({ owner: account }).then(({ nonce: nonce2 }) => {
|
|
6665
|
+
if (typeof nonce2 !== "number") {
|
|
6666
|
+
throw new Error("Failed to get owner nonce");
|
|
6667
|
+
}
|
|
6668
|
+
return nonce2;
|
|
6540
6669
|
}) : null;
|
|
6541
6670
|
let i = 0;
|
|
6542
6671
|
const sharesWithStatuses = statuses.reduce(
|
|
@@ -6661,8 +6790,128 @@ const getOperatorCapacity = async (config2, operatorId) => {
|
|
|
6661
6790
|
}),
|
|
6662
6791
|
config2.contract.ssv.read.getValidatorsPerOperatorLimit()
|
|
6663
6792
|
]);
|
|
6664
|
-
if (!operator) return 0;
|
|
6665
|
-
return limit - Number(operator.validatorCount);
|
|
6793
|
+
if (!operator?.operator) return 0;
|
|
6794
|
+
return limit - Number(operator.operator.validatorCount);
|
|
6795
|
+
};
|
|
6796
|
+
const isKeySharesFileShare = (share) => {
|
|
6797
|
+
return !!share && typeof share === "object" && "data" in share && "payload" in share;
|
|
6798
|
+
};
|
|
6799
|
+
const isPayloadOnlyShare = (share) => {
|
|
6800
|
+
return !!share && typeof share === "object" && "sharesData" in share && "publicKey" in share && "operatorIds" in share && !("data" in share) && !("payload" in share);
|
|
6801
|
+
};
|
|
6802
|
+
const toWebappOperatorKey = (operatorKey) => {
|
|
6803
|
+
if (operatorKey.startsWith("LS0tLS1CRUdJTi")) {
|
|
6804
|
+
return operatorKey;
|
|
6805
|
+
}
|
|
6806
|
+
return Buffer.from(operatorKey, "utf-8").toString("base64");
|
|
6807
|
+
};
|
|
6808
|
+
const buildOperatorMap = async (config2, shares, providedOperators) => {
|
|
6809
|
+
if (providedOperators) {
|
|
6810
|
+
return new Map(
|
|
6811
|
+
providedOperators.map((operator) => [
|
|
6812
|
+
operator.id,
|
|
6813
|
+
{
|
|
6814
|
+
...operator,
|
|
6815
|
+
operatorKey: toWebappOperatorKey(operator.operatorKey)
|
|
6816
|
+
}
|
|
6817
|
+
])
|
|
6818
|
+
);
|
|
6819
|
+
}
|
|
6820
|
+
const payloadShares = shares.filter(isPayloadOnlyShare);
|
|
6821
|
+
if (!payloadShares.length) {
|
|
6822
|
+
return /* @__PURE__ */ new Map();
|
|
6823
|
+
}
|
|
6824
|
+
const uniqueOperatorIds = [
|
|
6825
|
+
...new Set(payloadShares.flatMap((share) => share.operatorIds))
|
|
6826
|
+
];
|
|
6827
|
+
const { operators } = await config2.api.getOperators({
|
|
6828
|
+
operatorIds: uniqueOperatorIds.map(String)
|
|
6829
|
+
});
|
|
6830
|
+
if (operators.length !== uniqueOperatorIds.length) {
|
|
6831
|
+
throw new Error(
|
|
6832
|
+
"writeKeysharesFile could not fetch all operators required to build the webapp keyshares format."
|
|
6833
|
+
);
|
|
6834
|
+
}
|
|
6835
|
+
return new Map(
|
|
6836
|
+
operators.map((operator) => [
|
|
6837
|
+
Number(operator.id),
|
|
6838
|
+
{
|
|
6839
|
+
id: Number(operator.id),
|
|
6840
|
+
operatorKey: toWebappOperatorKey(operator.publicKey)
|
|
6841
|
+
}
|
|
6842
|
+
])
|
|
6843
|
+
);
|
|
6844
|
+
};
|
|
6845
|
+
const normalizeKeySharesItem = async (share, index, args, operatorMap) => {
|
|
6846
|
+
if (config.isKeySharesItem(share)) {
|
|
6847
|
+
return JSON.parse(share.toJson());
|
|
6848
|
+
}
|
|
6849
|
+
if (isKeySharesFileShare(share)) {
|
|
6850
|
+
return share;
|
|
6851
|
+
}
|
|
6852
|
+
if (!isPayloadOnlyShare(share)) {
|
|
6853
|
+
throw new Error(
|
|
6854
|
+
"writeKeysharesFile received an unsupported keyshares shape."
|
|
6855
|
+
);
|
|
6856
|
+
}
|
|
6857
|
+
if (!args.ownerAddress || typeof args.nonce !== "number") {
|
|
6858
|
+
throw new Error(
|
|
6859
|
+
"writeKeysharesFile requires ownerAddress and nonce when shares contain payload-only keyshares."
|
|
6860
|
+
);
|
|
6861
|
+
}
|
|
6862
|
+
const operators = share.operatorIds.map((operatorId) => {
|
|
6863
|
+
const operator = operatorMap.get(operatorId);
|
|
6864
|
+
if (!operator) {
|
|
6865
|
+
throw new Error(
|
|
6866
|
+
`writeKeysharesFile could not resolve operator ${operatorId} for the webapp keyshares format.`
|
|
6867
|
+
);
|
|
6868
|
+
}
|
|
6869
|
+
return operator;
|
|
6870
|
+
});
|
|
6871
|
+
return {
|
|
6872
|
+
data: {
|
|
6873
|
+
ownerAddress: args.ownerAddress,
|
|
6874
|
+
ownerNonce: args.nonce + index,
|
|
6875
|
+
publicKey: share.publicKey,
|
|
6876
|
+
operators
|
|
6877
|
+
},
|
|
6878
|
+
payload: share
|
|
6879
|
+
};
|
|
6880
|
+
};
|
|
6881
|
+
const getParentDirectory = (filePath) => {
|
|
6882
|
+
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
6883
|
+
const lastSeparatorIndex = normalizedPath.lastIndexOf("/");
|
|
6884
|
+
if (lastSeparatorIndex === -1) {
|
|
6885
|
+
return ".";
|
|
6886
|
+
}
|
|
6887
|
+
if (lastSeparatorIndex === 0) {
|
|
6888
|
+
return normalizedPath[0];
|
|
6889
|
+
}
|
|
6890
|
+
return normalizedPath.slice(0, lastSeparatorIndex);
|
|
6891
|
+
};
|
|
6892
|
+
const writeKeysharesFile = async (config2, args) => {
|
|
6893
|
+
const { path, shares } = args;
|
|
6894
|
+
if (!shares.length) {
|
|
6895
|
+
throw new Error(
|
|
6896
|
+
"writeKeysharesFile requires at least one keyshares item to write a file."
|
|
6897
|
+
);
|
|
6898
|
+
}
|
|
6899
|
+
const operatorMap = await buildOperatorMap(config2, shares, args.operators);
|
|
6900
|
+
const normalizedShares = await Promise.all(
|
|
6901
|
+
shares.map(
|
|
6902
|
+
(share, index) => normalizeKeySharesItem(share, index, args, operatorMap)
|
|
6903
|
+
)
|
|
6904
|
+
);
|
|
6905
|
+
const keySharesFile = {
|
|
6906
|
+
version: "v1.1.0",
|
|
6907
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6908
|
+
shares: normalizedShares
|
|
6909
|
+
};
|
|
6910
|
+
const { mkdir, writeFile } = await import("node:fs/promises");
|
|
6911
|
+
await mkdir(getParentDirectory(path), { recursive: true });
|
|
6912
|
+
await writeFile(path, JSON.stringify(keySharesFile, null, 2), {
|
|
6913
|
+
encoding: "utf-8"
|
|
6914
|
+
});
|
|
6666
6915
|
};
|
|
6667
6916
|
const computeDailyAmount = (value, days) => {
|
|
6668
6917
|
const scale = 10 ** 6;
|
|
@@ -6670,17 +6919,17 @@ const computeDailyAmount = (value, days) => {
|
|
|
6670
6919
|
return value * scaledDays * BigInt(config.globals.BLOCKS_PER_DAY) / BigInt(scale);
|
|
6671
6920
|
};
|
|
6672
6921
|
const calcDepositFromRunway = async (config$1, { clusterId, runway }) => {
|
|
6673
|
-
const cluster = await config$1.api.getCluster({ id: clusterId });
|
|
6922
|
+
const { cluster } = await config$1.api.getCluster({ id: clusterId });
|
|
6674
6923
|
if (!cluster) {
|
|
6675
6924
|
throw new Error("Cluster not found");
|
|
6676
6925
|
}
|
|
6677
|
-
const operators = await config$1.api.getOperators({
|
|
6926
|
+
const { operators } = await config$1.api.getOperators({
|
|
6678
6927
|
operatorIds: cluster.operatorIds
|
|
6679
6928
|
});
|
|
6680
6929
|
if (!operators) {
|
|
6681
6930
|
throw new Error("Operators not found");
|
|
6682
6931
|
}
|
|
6683
|
-
const daoValues = await config$1.api.getDaoValues({
|
|
6932
|
+
const { daovalues: daoValues } = await config$1.api.getDaoValues({
|
|
6684
6933
|
daoAddress: config$1.contractAddresses.setter
|
|
6685
6934
|
});
|
|
6686
6935
|
if (!daoValues) {
|
|
@@ -6712,6 +6961,10 @@ const calcDepositFromRunway = async (config$1, { clusterId, runway }) => {
|
|
|
6712
6961
|
};
|
|
6713
6962
|
const createUtils = (config2) => ({
|
|
6714
6963
|
generateKeyShares,
|
|
6964
|
+
writeKeysharesFile: writeKeysharesFile.bind(
|
|
6965
|
+
null,
|
|
6966
|
+
config2
|
|
6967
|
+
),
|
|
6715
6968
|
validateKeysharesJSON,
|
|
6716
6969
|
validateSharesPreRegistration: validateSharesPreRegistration.bind(
|
|
6717
6970
|
null,
|
|
@@ -6799,4 +7052,3 @@ exports.getQueries = getQueries;
|
|
|
6799
7052
|
exports.getValidator = getValidator;
|
|
6800
7053
|
exports.getValidators = getValidators;
|
|
6801
7054
|
exports.isConfig = isConfig;
|
|
6802
|
-
exports.toSolidityCluster = toSolidityCluster;
|