@ssv-labs/ssv-sdk 0.1.3 → 1.0.1

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.
Files changed (59) hide show
  1. package/README.html +4 -7
  2. package/README.md +37 -26
  3. package/dist/{KeyShares-B_4l2THg.js → KeyShares-Bk9uzOlK.js} +194 -51
  4. package/dist/{KeyShares-ClzHwMUy.mjs → KeyShares-Dlp4Pa3b.mjs} +198 -55
  5. package/dist/abi/mainnet/v4/getter.d.ts +699 -74
  6. package/dist/abi/mainnet/v4/setter.d.ts +939 -59
  7. package/dist/api/subgraph/index.d.ts +36 -1
  8. package/dist/config/create.d.ts +2 -2
  9. package/dist/config/globals.d.ts +3 -0
  10. package/dist/{globals-CDOcDUnk.mjs → config-BdEJjnYA.mjs} +107 -79
  11. package/dist/{globals-DsaKgq3v.js → config-ClGS9Tic.js} +73 -45
  12. package/dist/contract-interactions/create.d.ts +1 -1
  13. package/dist/contract-interactions/types.d.ts +9 -3
  14. package/dist/graphql/graphql.d.ts +4663 -922
  15. package/dist/keys.js +1 -1
  16. package/dist/keys.mjs +5 -5
  17. package/dist/libs/api/index.d.ts +2 -0
  18. package/dist/libs/cluster/index.d.ts +3 -1
  19. package/dist/libs/cluster/methods/deposit.d.ts +150 -4
  20. package/dist/libs/cluster/methods/exit-validators.d.ts +149 -0
  21. package/dist/libs/cluster/methods/index.d.ts +3 -1
  22. package/dist/libs/cluster/methods/liquidate-cluster.d.ts +149 -0
  23. package/dist/libs/cluster/methods/liquidate-ssv.d.ts +430 -0
  24. package/dist/libs/cluster/methods/migrate-cluster-to-eth.d.ts +431 -0
  25. package/dist/libs/cluster/methods/reactivate-cluster.d.ts +149 -0
  26. package/dist/libs/cluster/methods/register-validators.d.ts +2222 -309
  27. package/dist/libs/cluster/methods/remove-validators.d.ts +149 -0
  28. package/dist/libs/cluster/methods/set-fee-recipient.d.ts +149 -0
  29. package/dist/libs/cluster/methods/withdraw.d.ts +149 -0
  30. package/dist/libs/dao/index.d.ts +8 -0
  31. package/dist/libs/dao/methods/commit-root.d.ts +432 -0
  32. package/dist/libs/dao/methods/index.d.ts +3 -0
  33. package/dist/libs/dao/methods/update-network-fee-ssv.d.ts +430 -0
  34. package/dist/libs/dao/methods/withdraw-network-ssv-earnings.d.ts +430 -0
  35. package/dist/libs/operator/index.d.ts +1525 -32
  36. package/dist/libs/operator/methods.d.ts +1731 -2
  37. package/dist/libs/ssv-keys/Encryption/__test__/RsaKeys.d.ts +1 -1
  38. package/dist/libs/ssv-keys/KeyShares/KeySharesItem.d.ts +1 -1
  39. package/dist/libs/ssv-keys/SSVKeys.d.ts +1 -1
  40. package/dist/libs/ssv-keys/exceptions/index.d.ts +1 -1
  41. package/dist/libs/ssv-keys/index.d.ts +1 -1
  42. package/dist/libs/ssv-keys/interfaces/index.d.ts +2 -2
  43. package/dist/libs/utils/index.d.ts +6 -4
  44. package/dist/libs/utils/methods/calc-deposit-from-runway.d.ts +11 -0
  45. package/dist/libs/utils/methods/get-cluster-balance.d.ts +3 -1
  46. package/dist/libs/utils/methods/keyshares.d.ts +4 -2
  47. package/dist/libs/utils/methods/keystores.d.ts +4 -4
  48. package/dist/main.d.ts +1 -0
  49. package/dist/main.js +2714 -729
  50. package/dist/main.mjs +2746 -761
  51. package/dist/sdk.d.ts +8 -4
  52. package/dist/types/contract-interactions.d.ts +11 -0
  53. package/dist/types/methods.d.ts +4 -3
  54. package/dist/utils/cluster.d.ts +3 -3
  55. package/dist/utils/funding.d.ts +29 -0
  56. package/dist/utils/zod/config.d.ts +1 -1
  57. package/dist/utils.js +38 -38
  58. package/dist/utils.mjs +34 -34
  59. package/package.json +18 -6
package/README.html CHANGED
@@ -51,7 +51,7 @@
51
51
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
52
52
  </code></pre><h3 id="cluster-management">Cluster management </h3>
53
53
  <pre data-role="codeBlock" data-info="typescript" class="language-typescript typescript"><code><span class="token comment">// Get cluster balance</span>
54
- <span class="token keyword keyword-import">import</span> <span class="token punctuation">{</span> getClusterSnapshot <span class="token punctuation">}</span> <span class="token keyword keyword-from">from</span> <span class="token string">'@/utils/cluster'</span>
54
+ <span class="token keyword keyword-import">import</span> <span class="token punctuation">{</span> toSolidityCluster <span class="token punctuation">}</span> <span class="token keyword keyword-from">from</span> <span class="token string">'@/utils/cluster'</span>
55
55
  <span class="token keyword keyword-import">import</span> <span class="token punctuation">{</span> <span class="token constant">SSVSDK</span> <span class="token punctuation">}</span> <span class="token keyword keyword-from">from</span> <span class="token string">'ssv-sdk'</span>
56
56
 
57
57
  <span class="token comment">// Initialize with basic configuration</span>
@@ -66,7 +66,7 @@
66
66
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
67
67
 
68
68
  <span class="token keyword keyword-const">const</span> balance <span class="token operator">=</span> <span class="token keyword keyword-await">await</span> sdk<span class="token punctuation">.</span>contract<span class="token punctuation">.</span>write<span class="token punctuation">.</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
69
- cluster<span class="token operator">:</span> <span class="token function">getClusterSnapshot</span><span class="token punctuation">(</span>cluster<span class="token punctuation">)</span><span class="token punctuation">,</span>
69
+ cluster<span class="token operator">:</span> <span class="token function">toSolidityCluster</span><span class="token punctuation">(</span>cluster<span class="token punctuation">)</span><span class="token punctuation">,</span>
70
70
  clusterOwner<span class="token operator">:</span> <span class="token string">'0x'</span><span class="token punctuation">,</span>
71
71
  operatorIds<span class="token operator">:</span> operators<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>o<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token function">BigInt</span><span class="token punctuation">(</span>o<span class="token punctuation">.</span>id<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
72
72
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
@@ -76,11 +76,8 @@
76
76
  <span class="token keyword keyword-await">await</span> sdk<span class="token punctuation">.</span>clusters<span class="token punctuation">.</span><span class="token function">deposit</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
77
77
  id<span class="token operator">:</span> <span class="token string">'...'</span><span class="token punctuation">,</span>
78
78
  amount<span class="token operator">:</span> <span class="token function">parseEther</span><span class="token punctuation">(</span><span class="token string">'1.5'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
79
- options<span class="token operator">:</span> <span class="token punctuation">{</span>
80
- approve<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token comment">// Automatically triggers token approval transaction if the allowance is lower than the deposit amount</span>
81
- <span class="token punctuation">}</span><span class="token punctuation">,</span>
82
79
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
83
- </code></pre><h3 id="environment-setup-for-testing">Environment Setup for Testing </h3>
80
+ </code></pre><p><strong>Note:</strong> The current <code>sdk.clusters.deposit</code> path is payable and does not perform ERC-20 allowance checks or <code>approve</code> calls.</p><h3 id="environment-setup-for-testing">Environment Setup for Testing </h3>
84
81
  <p>To run tests, you'll need to set up your environment variables. Create a <code>.env</code> file in the root directory of your project using the provided <code>.env.example</code> as a template:</p>
85
82
  <pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token comment"># Copy the example env file</span>
86
83
  <span class="token function">cp</span> .env.example .env
@@ -99,4 +96,4 @@
99
96
 
100
97
 
101
98
 
102
- </body></html>
99
+ </body></html>
package/README.md CHANGED
@@ -18,9 +18,10 @@ The SSV SDK is a TypeScript library for interacting with the SSV network, enabli
18
18
 
19
19
  ## Core Modules
20
20
 
21
- The SDK consists of four main modules:
21
+ The SDK consists of five main modules:
22
22
 
23
23
  - **Clusters**: Manage validator clusters, handle deposits, and register validators
24
+ - **DAO**: Manage DAO-related actions and values
24
25
  - **Operators**: Interact with network operators and manage operator relationships
25
26
  - **API**: Access network data, query states, and retrieve operational information
26
27
  - **Utils**: Helper functions for keyshare validation, share generation, and other utilities
@@ -43,29 +44,29 @@ pnpm install @ssv-labs/ssv-sdk
43
44
  ### Initialize the SDK
44
45
 
45
46
  ```typescript
46
- import { SSVSDK, chains } from '@ssv-labs/ssv-sdk'
47
- import { createPublicClient, createWalletClient, http } from 'viem'
48
- import { privateKeyToAccount } from 'viem/accounts'
47
+ import { SSVSDK, chains } from '@ssv-labs/ssv-sdk';
48
+ import { createPublicClient, createWalletClient, http } from 'viem';
49
+ import { privateKeyToAccount } from 'viem/accounts';
49
50
 
50
- const chain = chains.mainnet // or chains.holesky
51
- const transport = http()
51
+ const chain = chains.mainnet; // or chains.hoodi
52
+ const transport = http();
52
53
 
53
54
  const publicClient = createPublicClient({
54
55
  chain,
55
56
  transport,
56
- })
57
+ });
57
58
 
58
- const account = privateKeyToAccount('0x...')
59
+ const account = privateKeyToAccount('0x...');
59
60
  const walletClient = createWalletClient({
60
61
  account,
61
62
  chain,
62
63
  transport,
63
- })
64
+ });
64
65
 
65
66
  const sdk = new SSVSDK({
66
67
  publicClient,
67
68
  walletClient,
68
- })
69
+ });
69
70
  ```
70
71
 
71
72
  ### API Examples
@@ -74,48 +75,58 @@ const sdk = new SSVSDK({
74
75
  // Query operators
75
76
  const operators = await sdk.api.getOperators({
76
77
  operatorIds: ['220', '221', '223', '224'],
77
- })
78
+ });
78
79
 
79
80
  // Get owner nonce
80
81
  const nonce = await sdk.api.getOwnerNonce({
81
82
  owner: 'your_wallet_address',
82
- })
83
+ });
83
84
  ```
84
85
 
86
+ ### API Compatibility Notes
87
+
88
+ `getClusterSnapshot` was renamed in `v1.0.0`.
89
+
90
+ | SDK version | Method name |
91
+ | ----------- | ------------------------------------ |
92
+ | `0.1.x` | `sdk.api.getClusterSnapshot({ id })` |
93
+ | `1.x` | `sdk.api.toSolidityCluster({ id })` |
94
+
95
+ `sdk.api.getClusterSnapshot` is available as a deprecated alias in current `1.x` releases for compatibility with `0.1.x` code.
96
+
85
97
  ### Cluster Management
86
98
 
87
99
  ```typescript
88
- import { parseEther } from 'viem'
100
+ import { parseEther } from 'viem';
89
101
 
90
102
  // Deposit to cluster
91
- await sdk.clusters.deposit(
92
- {
93
- id: 'your_cluster_id',
94
- amount: parseEther('30'),
95
- },
96
- {
97
- approve: true, // Auto-approve token if needed
98
- },
99
- )
103
+ await sdk.clusters.deposit({
104
+ id: 'your_cluster_id',
105
+ amount: parseEther('30'),
106
+ });
100
107
  ```
101
108
 
109
+ > Note: The current `sdk.clusters.deposit` path is payable and does not perform ERC-20 allowance checks or `approve` calls.
110
+
102
111
  ### Register Validators
112
+
103
113
  To register validators, you'll need to:
104
114
 
105
115
  1. Create shares from your keyshares JSON file
106
116
  2. Register the validator using the created shares
117
+
107
118
  ```typescript
108
- import { parseEther } from 'viem'
119
+ import { parseEther } from 'viem';
109
120
 
110
121
  // Your keyshares JSON file containing the validator's data
111
- import keyshares from 'path/to/keyshares.json'
122
+ import keyshares from 'path/to/keyshares.json';
112
123
 
113
124
  // First, validate and create shares from your keyshares
114
125
  try {
115
126
  const result = await sdk.utils.validateSharesPreRegistration({
116
127
  operatorIds: ['220', '221', '223', '224'],
117
128
  keyshares,
118
- })
129
+ });
119
130
 
120
131
  // Register validators using the clusters API
121
132
  const receipt = await sdk.clusters
@@ -125,7 +136,7 @@ try {
125
136
  depositAmount: parseEther('2'),
126
137
  },
127
138
  })
128
- .then((tx) => tx.wait())
139
+ .then((tx) => tx.wait());
129
140
  } catch (e) {
130
141
  // something went wrong
131
142
  }