@obolnetwork/obol-sdk 2.11.4 → 2.11.5-rc.0

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 (140) hide show
  1. package/dist/cjs/src/index.js +17457 -382
  2. package/dist/cjs/src/index.js.map +1 -0
  3. package/dist/esm/src/index.js +17424 -361
  4. package/dist/esm/src/index.js.map +1 -0
  5. package/dist/types/src/constants.d.ts +1 -2
  6. package/dist/types/src/eoa/eoaHelpers.d.ts +1 -1
  7. package/dist/types/src/exits/verificationHelpers.d.ts +0 -2
  8. package/dist/types/src/incentives/incentiveHelpers.d.ts +1 -1
  9. package/dist/types/src/splits/splitHelpers.d.ts +3 -3
  10. package/dist/types/src/utils.d.ts +2 -2
  11. package/dist/types/src/verification/common.d.ts +0 -2
  12. package/dist/types/src/verification/signature-validator.d.ts +4 -4
  13. package/dist/types/src/verification/v1.10.0.d.ts +1 -1
  14. package/dist/types/src/verification/v1.6.0.d.ts +1 -1
  15. package/dist/types/src/verification/v1.7.0.d.ts +1 -1
  16. package/dist/types/src/verification/v1.8.0.d.ts +1 -1
  17. package/dist/types/test/client/methods.spec.d.ts +17 -0
  18. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  19. package/dist/types/tsup.config.d.ts +2 -0
  20. package/package.json +79 -54
  21. package/dist/cjs/package.json +0 -139
  22. package/dist/cjs/src/abi/BatchDeposit.js +0 -120
  23. package/dist/cjs/src/abi/MerkleDistributorWithDeadline.js +0 -73
  24. package/dist/cjs/src/abi/Multicall3.js +0 -253
  25. package/dist/cjs/src/abi/OVM.js +0 -627
  26. package/dist/cjs/src/abi/OWR.js +0 -304
  27. package/dist/cjs/src/abi/SplitMain.js +0 -929
  28. package/dist/cjs/src/abi/splitV2FactoryAbi.js +0 -420
  29. package/dist/cjs/src/ajv.js +0 -136
  30. package/dist/cjs/src/base.js +0 -42
  31. package/dist/cjs/src/bytecodes.js +0 -19
  32. package/dist/cjs/src/constants.js +0 -272
  33. package/dist/cjs/src/eoa/eoa.js +0 -132
  34. package/dist/cjs/src/eoa/eoaHelpers.js +0 -82
  35. package/dist/cjs/src/errors.js +0 -11
  36. package/dist/cjs/src/exits/ethUtils.js +0 -57
  37. package/dist/cjs/src/exits/exit.js +0 -502
  38. package/dist/cjs/src/exits/verificationHelpers.js +0 -86
  39. package/dist/cjs/src/incentives/incentiveHelpers.js +0 -39
  40. package/dist/cjs/src/incentives/incentives.js +0 -119
  41. package/dist/cjs/src/schema.js +0 -352
  42. package/dist/cjs/src/services.js +0 -33
  43. package/dist/cjs/src/splits/splitHelpers.js +0 -571
  44. package/dist/cjs/src/splits/splits.js +0 -366
  45. package/dist/cjs/src/types.js +0 -29
  46. package/dist/cjs/src/utils.js +0 -77
  47. package/dist/cjs/src/verification/common.js +0 -355
  48. package/dist/cjs/src/verification/signature-validator.js +0 -73
  49. package/dist/cjs/src/verification/sszTypes.js +0 -69
  50. package/dist/cjs/src/verification/termsAndConditions.js +0 -40
  51. package/dist/cjs/src/verification/v1.10.0.js +0 -146
  52. package/dist/cjs/src/verification/v1.6.0.js +0 -149
  53. package/dist/cjs/src/verification/v1.7.0.js +0 -173
  54. package/dist/cjs/src/verification/v1.8.0.js +0 -196
  55. package/dist/cjs/test/client/ajv.spec.js +0 -320
  56. package/dist/cjs/test/client/methods.spec.js +0 -418
  57. package/dist/cjs/test/eoa/eoa.spec.js +0 -176
  58. package/dist/cjs/test/exit/ethUtils.spec.js +0 -83
  59. package/dist/cjs/test/exit/exit.spec.js +0 -399
  60. package/dist/cjs/test/exit/verificationHelpers.spec.js +0 -68
  61. package/dist/cjs/test/fixtures.js +0 -896
  62. package/dist/cjs/test/incentives/incentives.spec.js +0 -202
  63. package/dist/cjs/test/splits/splits.spec.js +0 -402
  64. package/dist/esm/package.json +0 -139
  65. package/dist/esm/src/abi/BatchDeposit.js +0 -117
  66. package/dist/esm/src/abi/MerkleDistributorWithDeadline.js +0 -70
  67. package/dist/esm/src/abi/Multicall3.js +0 -250
  68. package/dist/esm/src/abi/OVM.js +0 -624
  69. package/dist/esm/src/abi/OWR.js +0 -301
  70. package/dist/esm/src/abi/SplitMain.js +0 -926
  71. package/dist/esm/src/abi/splitV2FactoryAbi.js +0 -417
  72. package/dist/esm/src/ajv.js +0 -129
  73. package/dist/esm/src/base.js +0 -38
  74. package/dist/esm/src/bytecodes.js +0 -16
  75. package/dist/esm/src/constants.js +0 -238
  76. package/dist/esm/src/eoa/eoa.js +0 -128
  77. package/dist/esm/src/eoa/eoaHelpers.js +0 -77
  78. package/dist/esm/src/errors.js +0 -7
  79. package/dist/esm/src/exits/ethUtils.js +0 -52
  80. package/dist/esm/src/exits/exit.js +0 -475
  81. package/dist/esm/src/exits/verificationHelpers.js +0 -81
  82. package/dist/esm/src/incentives/incentiveHelpers.js +0 -34
  83. package/dist/esm/src/incentives/incentives.js +0 -115
  84. package/dist/esm/src/schema.js +0 -349
  85. package/dist/esm/src/services.js +0 -29
  86. package/dist/esm/src/splits/splitHelpers.js +0 -554
  87. package/dist/esm/src/splits/splits.js +0 -362
  88. package/dist/esm/src/types.js +0 -26
  89. package/dist/esm/src/utils.js +0 -68
  90. package/dist/esm/src/verification/common.js +0 -319
  91. package/dist/esm/src/verification/signature-validator.js +0 -64
  92. package/dist/esm/src/verification/sszTypes.js +0 -64
  93. package/dist/esm/src/verification/termsAndConditions.js +0 -33
  94. package/dist/esm/src/verification/v1.10.0.js +0 -140
  95. package/dist/esm/src/verification/v1.6.0.js +0 -142
  96. package/dist/esm/src/verification/v1.7.0.js +0 -166
  97. package/dist/esm/src/verification/v1.8.0.js +0 -189
  98. package/dist/esm/test/client/ajv.spec.js +0 -318
  99. package/dist/esm/test/client/methods.spec.js +0 -393
  100. package/dist/esm/test/eoa/eoa.spec.js +0 -174
  101. package/dist/esm/test/exit/ethUtils.spec.js +0 -81
  102. package/dist/esm/test/exit/exit.spec.js +0 -374
  103. package/dist/esm/test/exit/verificationHelpers.spec.js +0 -66
  104. package/dist/esm/test/fixtures.js +0 -893
  105. package/dist/esm/test/incentives/incentives.spec.js +0 -177
  106. package/dist/esm/test/splits/splits.spec.js +0 -400
  107. package/src/abi/BatchDeposit.ts +0 -117
  108. package/src/abi/MerkleDistributorWithDeadline.ts +0 -70
  109. package/src/abi/Multicall3.ts +0 -250
  110. package/src/abi/OVM.ts +0 -624
  111. package/src/abi/OWR.ts +0 -302
  112. package/src/abi/SplitMain.ts +0 -927
  113. package/src/abi/splitV2FactoryAbi.ts +0 -417
  114. package/src/ajv.ts +0 -191
  115. package/src/base.ts +0 -54
  116. package/src/bytecodes.ts +0 -32
  117. package/src/constants.ts +0 -309
  118. package/src/eoa/eoa.ts +0 -153
  119. package/src/eoa/eoaHelpers.ts +0 -112
  120. package/src/errors.ts +0 -8
  121. package/src/exits/ethUtils.ts +0 -49
  122. package/src/exits/exit.ts +0 -661
  123. package/src/exits/verificationHelpers.ts +0 -110
  124. package/src/incentives/incentiveHelpers.ts +0 -55
  125. package/src/incentives/incentives.ts +0 -153
  126. package/src/index.ts +0 -614
  127. package/src/schema.ts +0 -376
  128. package/src/services.ts +0 -24
  129. package/src/splits/splitHelpers.ts +0 -1032
  130. package/src/splits/splits.ts +0 -504
  131. package/src/types.ts +0 -687
  132. package/src/utils.ts +0 -88
  133. package/src/verification/common.ts +0 -532
  134. package/src/verification/signature-validator.ts +0 -103
  135. package/src/verification/sszTypes.ts +0 -88
  136. package/src/verification/termsAndConditions.ts +0 -32
  137. package/src/verification/v1.10.0.ts +0 -245
  138. package/src/verification/v1.6.0.ts +0 -256
  139. package/src/verification/v1.7.0.ts +0 -309
  140. package/src/verification/v1.8.0.ts +0 -340
@@ -1,238 +0,0 @@
1
- import pjson from '../package.json';
2
- import { FORK_MAPPING } from './types';
3
- import { HOLESKY_MULTICALL3_BYTECODE, HOLESKY_OVM_FACTORY_BYTECODE, HOLESKY_OWR_FACTORY_BYTECODE, HOLESKY_SPLITMAIN_BYTECODE, HOODI_MULTICALL3_BYTECODE, HOODI_OVM_FACTORY_BYTECODE, HOODI_OWR_FACTORY_BYTECODE, HOODI_SPLIT_V2_FACTORY_BYTECODE, HOODI_SPLITMAIN_BYTECODE, HOODI_WAREHOUSE_BYTECODE, MAINNET_MULTICALL3_BYTECODE, MAINNET_OVM_FACTORY_BYTECODE, MAINNET_OWR_FACTORY_BYTECODE, MAINNET_SPLIT_V2_FACTORY_BYTECODE, MAINNET_SPLITMAIN_BYTECODE, MAINNET_WAREHOUSE_BYTECODE, } from './bytecodes';
4
- import * as dotenv from 'dotenv';
5
- dotenv.config();
6
- export const CONFLICT_ERROR_MSG = 'Conflict';
7
- export const EIP712_DOMAIN_NAME = 'Obol';
8
- export const EIP712_DOMAIN_VERSION = '1';
9
- export const CreatorConfigHashSigningTypes = {
10
- CreatorConfigHash: [{ name: 'creator_config_hash', type: 'string' }],
11
- };
12
- export const TermsAndConditionsSigningTypes = {
13
- TermsAndConditions: [
14
- { name: 'terms_and_conditions_hash', type: 'string' },
15
- { name: 'version', type: 'uint256' },
16
- ],
17
- };
18
- const EIP712Domain = [
19
- { name: 'name', type: 'string' },
20
- { name: 'version', type: 'string' },
21
- { name: 'chainId', type: 'uint256' },
22
- ];
23
- export const Domain = (chainId) => {
24
- const typeDataDomain = {
25
- name: EIP712_DOMAIN_NAME,
26
- version: EIP712_DOMAIN_VERSION,
27
- };
28
- if (chainId) {
29
- typeDataDomain.chainId = chainId;
30
- }
31
- return typeDataDomain;
32
- };
33
- export const CreatorTypedMessage = Object.assign({ EIP712Domain }, CreatorConfigHashSigningTypes);
34
- // A conflict once updateDefinition is merged
35
- export const EnrSigningTypes = {
36
- ENR: [{ name: 'enr', type: 'string' }],
37
- };
38
- export const OperatorConfigHashSigningTypes = {
39
- OperatorConfigHash: [{ name: 'operator_config_hash', type: 'string' }],
40
- };
41
- export const OperatorTypedMessage = Object.assign({ EIP712Domain }, OperatorConfigHashSigningTypes);
42
- export const ENRTypedMessage = Object.assign({ EIP712Domain }, EnrSigningTypes);
43
- export const signCreatorConfigHashPayload = (payload, chainId) => {
44
- return {
45
- types: CreatorTypedMessage,
46
- primaryType: 'CreatorConfigHash',
47
- domain: {
48
- name: EIP712_DOMAIN_NAME,
49
- version: EIP712_DOMAIN_VERSION,
50
- chainId,
51
- },
52
- message: payload,
53
- };
54
- };
55
- export const signOperatorConfigHashPayload = (payload, chainId) => {
56
- return {
57
- types: OperatorTypedMessage,
58
- primaryType: 'OperatorConfigHash',
59
- domain: {
60
- name: EIP712_DOMAIN_NAME,
61
- version: EIP712_DOMAIN_VERSION,
62
- chainId,
63
- },
64
- message: payload,
65
- };
66
- };
67
- export const signEnrPayload = (payload, chainId) => {
68
- return {
69
- types: ENRTypedMessage,
70
- primaryType: 'ENR',
71
- domain: {
72
- name: EIP712_DOMAIN_NAME,
73
- version: EIP712_DOMAIN_VERSION,
74
- chainId,
75
- },
76
- message: payload,
77
- };
78
- };
79
- export const DKG_ALGORITHM = 'default';
80
- export const CONFIG_VERSION = 'v1.10.0';
81
- export const SDK_VERSION = pjson.version;
82
- export const DOMAIN_APPLICATION_BUILDER = '00000001';
83
- export const DOMAIN_DEPOSIT = '03000000';
84
- export const GENESIS_VALIDATOR_ROOT = '0000000000000000000000000000000000000000000000000000000000000000';
85
- // Flow used to create definition
86
- export var DefinitionFlow;
87
- (function (DefinitionFlow) {
88
- DefinitionFlow["Group"] = "LP-Group";
89
- DefinitionFlow["Solo"] = "LP-Solo";
90
- DefinitionFlow["Charon"] = "Charon-Command";
91
- })(DefinitionFlow || (DefinitionFlow = {}));
92
- export const DEFAULT_BASE_URL = 'https://api.obol.tech';
93
- export const DEFAULT_BASE_VERSION = 'v1';
94
- export const DEFAULT_CHAIN_ID = 17000;
95
- export const ETHER_TO_GWEI = 10 ** 9;
96
- export const TERMS_AND_CONDITIONS_VERSION = 1;
97
- export const TERMS_AND_CONDITIONS_URL = TERMS_AND_CONDITIONS_VERSION === 1
98
- ? 'https://obol.org/terms.pdf'
99
- : `https://obol.org/${TERMS_AND_CONDITIONS_VERSION}/terms.pdf`;
100
- export const TERMS_AND_CONDITIONS_HASH = '0xd33721644e8f3afab1495a74abe3523cec12d48b8da6cb760972492ca3f1a273';
101
- export const AVAILABLE_SPLITTER_CHAINS = {
102
- [FORK_MAPPING['0x00000000']]: true, // Mainnet
103
- [FORK_MAPPING['0x01017000']]: true, // Holesky
104
- [FORK_MAPPING['0x10000910']]: true, // Hoodi
105
- };
106
- export const isChainSupportedForSplitters = (chainId) => {
107
- return chainId in AVAILABLE_SPLITTER_CHAINS;
108
- };
109
- export const CHAIN_CONFIGURATION = {
110
- [FORK_MAPPING['0x00000000']]: {
111
- SPLITMAIN_CONTRACT: {
112
- address: '0x2ed6c4B5dA6378c7897AC67Ba9e43102Feb694EE',
113
- bytecode: MAINNET_SPLITMAIN_BYTECODE,
114
- },
115
- MULTICALL3_CONTRACT: {
116
- address: '0xcA11bde05977b3631167028862bE2a173976CA11',
117
- bytecode: MAINNET_MULTICALL3_BYTECODE,
118
- },
119
- OWR_FACTORY_CONTRACT: {
120
- address: '0x119acd7844cbdd5fc09b1c6a4408f490c8f7f522',
121
- bytecode: MAINNET_OWR_FACTORY_BYTECODE,
122
- },
123
- RETROACTIVE_FUNDING_CONTRACT: {
124
- address: '0xDe5aE4De36c966747Ea7DF13BD9589642e2B1D0d',
125
- bytecode: '',
126
- },
127
- // OVM and SplitV2 Contract Addresses
128
- OVM_FACTORY_CONTRACT: {
129
- address: '0xA755669f314022ED2158e93867af5183E88370fe',
130
- bytecode: MAINNET_OVM_FACTORY_BYTECODE,
131
- },
132
- WAREHOUSE_CONTRACT: {
133
- address: '0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8',
134
- bytecode: MAINNET_WAREHOUSE_BYTECODE,
135
- },
136
- SPLIT_V2_FACTORY_CONTRACT: {
137
- address: '0x5cbA88D55Cec83caD5A105Ad40C8c9aF20bE21d1',
138
- bytecode: MAINNET_SPLIT_V2_FACTORY_BYTECODE,
139
- },
140
- EOA_WITHDRAWAL_CONTRACT: {
141
- address: '0x00000961Ef480Eb55e80D19ad83579A64c007002',
142
- },
143
- BATCH_DEPOSIT_CONTRACT: {
144
- address: '0xcD7a6C118Ac8F6544BC5076F2D8Fb86D2C546756',
145
- },
146
- },
147
- [FORK_MAPPING['0x01017000']]: {
148
- SPLITMAIN_CONTRACT: {
149
- address: '0xfC8a305728051367797DADE6Aa0344E0987f5286',
150
- bytecode: HOLESKY_SPLITMAIN_BYTECODE,
151
- },
152
- MULTICALL3_CONTRACT: {
153
- address: '0xcA11bde05977b3631167028862bE2a173976CA11',
154
- bytecode: HOLESKY_MULTICALL3_BYTECODE,
155
- },
156
- OWR_FACTORY_CONTRACT: {
157
- address: '0xc0961353fcc43a99e3041db07ac646720e116256',
158
- bytecode: HOLESKY_OWR_FACTORY_BYTECODE,
159
- },
160
- RETROACTIVE_FUNDING_CONTRACT: {
161
- address: '0x43F641fA70e09f0326ac66b4Ef0C416EaEcBC6f5',
162
- bytecode: '',
163
- },
164
- EOA_WITHDRAWAL_CONTRACT: {
165
- address: '0x00000961Ef480Eb55e80D19ad83579A64c007002',
166
- },
167
- OVM_FACTORY_CONTRACT: {
168
- address: '0x4B157b79277E44D12C234680ACE17Db028075EA5',
169
- bytecode: HOLESKY_OVM_FACTORY_BYTECODE,
170
- },
171
- },
172
- [FORK_MAPPING['0x10000910']]: {
173
- SPLITMAIN_CONTRACT: {
174
- address: '0xc05ae267291705ac16F75283572294ed2a91CBc7',
175
- bytecode: HOODI_SPLITMAIN_BYTECODE,
176
- },
177
- MULTICALL3_CONTRACT: {
178
- address: '0xcA11bde05977b3631167028862bE2a173976CA11',
179
- bytecode: HOODI_MULTICALL3_BYTECODE,
180
- },
181
- OWR_FACTORY_CONTRACT: {
182
- address: '0x9ff0c649d0bf5fe7efa4d72e94bed7302ed5c8d7',
183
- bytecode: HOODI_OWR_FACTORY_BYTECODE,
184
- },
185
- RETROACTIVE_FUNDING_CONTRACT: {
186
- address: '0x43F641fA70e09f0326ac66b4Ef0C416EaEcBC6f5',
187
- bytecode: '',
188
- },
189
- // OVM and SplitV2 Contract Addresses
190
- OVM_FACTORY_CONTRACT: {
191
- address: '0x885E7D97E3987BA57EF0d693C508d675e4Bf82FC',
192
- bytecode: HOODI_OVM_FACTORY_BYTECODE,
193
- },
194
- WAREHOUSE_CONTRACT: {
195
- address: '0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8',
196
- bytecode: HOODI_WAREHOUSE_BYTECODE,
197
- },
198
- SPLIT_V2_FACTORY_CONTRACT: {
199
- address: '0x5cbA88D55Cec83caD5A105Ad40C8c9aF20bE21d1',
200
- bytecode: HOODI_SPLIT_V2_FACTORY_BYTECODE,
201
- },
202
- EOA_WITHDRAWAL_CONTRACT: {
203
- address: '0x00000961Ef480Eb55e80D19ad83579A64c007002',
204
- },
205
- BATCH_DEPOSIT_CONTRACT: {
206
- address: '0x4c9506eE2fCd962f03022D9d8ebf6f7828abEfaf',
207
- },
208
- },
209
- };
210
- export const DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT = 1;
211
- export const DEFAULT_RETROACTIVE_FUNDING_TOTAL_SPLIT = 0.1;
212
- // OVM and SplitV2 Default Constants
213
- export const SPLITS_V2_SALT = '0x2fa740d39f3b04b2c7ef4e9f9e1a6e38f4c72c1a91d8595d5d31a3adf17c6b12';
214
- export const PRINCIPAL_THRESHOLD = 16;
215
- export const OBOL_SDK_EMAIL = 'sdk@dvlabs.tech';
216
- export const PROVIDER_MAP = {
217
- 1: `${process.env.RPC_MAINNET}`, // Mainnet
218
- 17000: `${process.env.RPC_HOLESKY}`, // Holesky
219
- 11155111: `${process.env.RPC_SEPOLIA}`, // Sepolia
220
- 100: `${process.env.RPC_GNOSIS}`, // Gnosis
221
- 560048: `${process.env.RPC_HOODI}`, // Hoodi
222
- };
223
- /**
224
- * Maps base fork versions to their corresponding Capella fork versions.
225
- * Example: Mainnet Capella fork version.
226
- */
227
- export const CAPELLA_FORK_MAPPING = {
228
- '0x00000000': '0x03000000', // Mainnet
229
- '0x00001020': '0x03001020', // Goerli
230
- '0x00000064': '0x03000064', // Gnosis
231
- '0x90000069': '0x90000072', // Sepolia
232
- '0x01017000': '0x04017000', // Holesky
233
- '0x10000910': '0x40000910', // Hoodi
234
- };
235
- export const CHAIN_PUBLIC_RPC_URL = {
236
- 1: 'https://ethereum-rpc.publicnode.com', // Mainnet
237
- 560048: 'https://ethereum-hoodi-rpc.publicnode.com', // Hoodi
238
- };
@@ -1,128 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { submitEOAWithdrawalRequest, submitEOABatchDeposit, } from './eoaHelpers';
11
- import { validatePayload } from '../ajv';
12
- import { eoaWithdrawalPayloadSchema, eoaDepositPayloadSchema } from '../schema';
13
- import { CHAIN_CONFIGURATION } from '../constants';
14
- /**
15
- * EOA can be used for managing EOA (Externally Owned Account) operations like withdrawals.
16
- * @class
17
- * @internal Access it through Client.eoa.
18
- * @example
19
- * const obolClient = new Client(config);
20
- * await obolClient.eoa.requestWithdrawal(EOAWithdrawalPayload);
21
- */
22
- export class EOA {
23
- constructor(signer, chainId, provider) {
24
- this.signer = signer;
25
- this.chainId = chainId;
26
- this.provider = provider;
27
- }
28
- /**
29
- * Requests withdrawal from an EOA contract.
30
- *
31
- * This method allows requesting withdrawal of validator funds.
32
- * The withdrawal request includes validator public key and corresponding withdrawal amount.
33
- *
34
- * @remarks
35
- * **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
36
- * and not pushed to version control.
37
- *
38
- * @param {EOAWithdrawalPayload} payload - Data needed to request withdrawal
39
- * @returns {Promise<{txHash: string}>} Transaction hash of the withdrawal request
40
- * @throws Will throw an error if the signer is not provided or the request fails
41
- *
42
- * An example of how to use requestWithdrawal:
43
- * ```typescript
44
- * const result = await client.eoa.requestWithdrawal({
45
- * pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
46
- * allocation: 32, // 32 ETH
47
- * requiredFee: '1' // in wei
48
- * });
49
- * console.log('Withdrawal requested:', result.txHash);
50
- * ```
51
- */
52
- requestWithdrawal(payload) {
53
- var _a;
54
- return __awaiter(this, void 0, void 0, function* () {
55
- if (!this.signer) {
56
- throw new Error('Signer is required in requestWithdrawal');
57
- }
58
- if (!this.provider) {
59
- throw new Error('Provider is required in requestWithdrawal');
60
- }
61
- const chainConfig = CHAIN_CONFIGURATION[this.chainId];
62
- if (!((_a = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.EOA_WITHDRAWAL_CONTRACT) === null || _a === void 0 ? void 0 : _a.address)) {
63
- throw new Error(`EOA withdrawal contract is not configured for chain ${this.chainId}`);
64
- }
65
- const validatedPayload = validatePayload(payload, eoaWithdrawalPayloadSchema);
66
- const withdrawalAddress = yield this.signer.getAddress();
67
- return yield submitEOAWithdrawalRequest({
68
- pubkey: validatedPayload.pubkey,
69
- allocation: validatedPayload.allocation,
70
- withdrawalAddress,
71
- withdrawalContractAddress: chainConfig.EOA_WITHDRAWAL_CONTRACT.address,
72
- requiredFee: validatedPayload.requiredFee,
73
- chainId: this.chainId,
74
- signer: this.signer,
75
- provider: this.provider,
76
- });
77
- });
78
- }
79
- /**
80
- * Deposits to batch deposit contract.
81
- *
82
- * This method allows depositing multiple validators to the Ethereum beacon chain
83
- * using the Pier Two batch deposit contract for gas efficiency.
84
- * Each deposit includes validator public key, withdrawal credentials, signature, and amount.
85
- *
86
- * @remarks
87
- * **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
88
- * and not pushed to version control.
89
- *
90
- * **⚠️ Gas Limit:** Due to EVM constraints, it is recommended to deposit in batches of up to 500 at a time.
91
- *
92
- * @param {EOADepositPayload} payload - Data needed to deposit to batch contract
93
- * @returns {Promise<{txHashes: string[]}>} Array of transaction hashes for all batches
94
- * @throws Will throw an error if the signer is not provided, contract is not configured, or the deposit fails
95
- *
96
- * An example of how to use deposit:
97
- * ```typescript
98
- * const result = await client.eoa.deposit({
99
- * deposits: [{
100
- * pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
101
- * withdrawal_credentials: '0x1234567890123456789012345678901234567890',
102
- * deposit_data_root: '0x1234567890123456789012345678901234567890123456789012345678901234',
103
- * signature: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
104
- * amount: '32000000000000000000' // 32 ETH in wei
105
- * }]
106
- * });
107
- * console.log('Deposits completed:', result.txHashes);
108
- * ```
109
- */
110
- deposit(payload) {
111
- var _a;
112
- return __awaiter(this, void 0, void 0, function* () {
113
- if (!this.signer) {
114
- throw new Error('Signer is required in deposit');
115
- }
116
- const chainConfig = CHAIN_CONFIGURATION[this.chainId];
117
- if (!((_a = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.BATCH_DEPOSIT_CONTRACT) === null || _a === void 0 ? void 0 : _a.address)) {
118
- throw new Error(`Batch deposit contract is not configured for chain ${this.chainId}`);
119
- }
120
- const validatedPayload = validatePayload(payload, eoaDepositPayloadSchema);
121
- return yield submitEOABatchDeposit({
122
- deposits: validatedPayload.deposits,
123
- batchDepositContractAddress: chainConfig.BATCH_DEPOSIT_CONTRACT.address,
124
- signer: this.signer,
125
- });
126
- });
127
- }
128
- }
@@ -1,77 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ETHER_TO_GWEI } from '../constants';
11
- import { Contract } from 'ethers';
12
- import { BatchDepositContract } from '../abi/BatchDeposit';
13
- /**
14
- * Helper function to submit withdrawal request for EOA
15
- */
16
- export function submitEOAWithdrawalRequest({ pubkey, allocation, withdrawalAddress, withdrawalContractAddress, requiredFee, chainId, signer, provider, }) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- if (!withdrawalAddress)
19
- throw new Error('No withdrawal address provided');
20
- if (!allocation)
21
- throw new Error('No allocation provided');
22
- const amountInGwei = BigInt(Math.floor(Number(allocation) * ETHER_TO_GWEI));
23
- const data = `0x${pubkey.slice(2)}${amountInGwei.toString(16).padStart(16, '0')}`;
24
- const tx = yield signer.sendTransaction({
25
- to: withdrawalContractAddress,
26
- chainId,
27
- value: BigInt(requiredFee),
28
- data: data,
29
- });
30
- const receipt = yield tx.wait();
31
- if (!receipt)
32
- return { txHash: null };
33
- return { txHash: receipt.hash };
34
- });
35
- }
36
- /**
37
- * Helper function to submit batch deposit request for EOA
38
- */
39
- export function submitEOABatchDeposit({ deposits, batchDepositContractAddress, signer, }) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- if (!deposits || deposits.length === 0) {
42
- throw new Error('No deposits provided');
43
- }
44
- // Create contract instance
45
- const batchDepositContract = new Contract(batchDepositContractAddress, BatchDepositContract.abi, signer);
46
- const BATCH_SIZE = 500;
47
- const txHashes = [];
48
- try {
49
- // Process deposits in batches of 500
50
- for (let i = 0; i < deposits.length; i += BATCH_SIZE) {
51
- const batchDeposits = deposits.slice(i, i + BATCH_SIZE);
52
- // Calculate total value needed for this batch
53
- const totalValue = batchDeposits.reduce((sum, deposit) => sum + BigInt(deposit.amount), BigInt(0));
54
- // Prepare deposit data for this batch
55
- const depositData = batchDeposits.map(deposit => ({
56
- pubKey: deposit.pubkey,
57
- withdrawalCredentials: deposit.withdrawal_credentials,
58
- signature: deposit.signature,
59
- depositDataRoot: deposit.deposit_data_root,
60
- amount: BigInt(deposit.amount),
61
- }));
62
- // Execute batch deposit for this batch
63
- const tx = yield batchDepositContract.batchDeposit(depositData, {
64
- value: totalValue,
65
- });
66
- const receipt = yield tx.wait();
67
- if (receipt === null || receipt === void 0 ? void 0 : receipt.hash) {
68
- txHashes.push(receipt.hash);
69
- }
70
- }
71
- return { txHashes };
72
- }
73
- catch (error) {
74
- throw new Error("Failed to submit batch deposit'}");
75
- }
76
- });
77
- }
@@ -1,7 +0,0 @@
1
- export class ConflictError extends Error {
2
- constructor() {
3
- super('This Cluster has been already posted.');
4
- this.name = 'ConflictError';
5
- Object.setPrototypeOf(this, ConflictError.prototype);
6
- }
7
- }
@@ -1,52 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { CAPELLA_FORK_MAPPING } from '../constants';
11
- /**
12
- * Retrieves the Capella fork version for a given base fork version.
13
- * @param fork_version - The base fork version string (e.g., '0x00000000' for mainnet).
14
- * @returns A promise that resolves to the Capella fork version string, or null if not found.
15
- */
16
- export function getCapellaFork(fork_version) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- // Ensure the CAPELLA_FORK_MAPPING uses the base fork_version as key
19
- if (CAPELLA_FORK_MAPPING[fork_version]) {
20
- return CAPELLA_FORK_MAPPING[fork_version];
21
- }
22
- return null;
23
- });
24
- }
25
- /**
26
- * Fetches the genesis validators root from a beacon node.
27
- * @param beaconNodeApiUrl - The base URL of the beacon node API (e.g., http://localhost:5052).
28
- * @returns A promise that resolves to the genesis_validators_root string, or null on error.
29
- * @throws Will throw an error if the network corresponding to the fork_version is not supported or if the HTTP request fails.
30
- */
31
- export function getGenesisValidatorsRoot(beaconNodeApiUrl) {
32
- var _a;
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const genesisEndpoint = `${beaconNodeApiUrl}/eth/v1/beacon/genesis`;
35
- try {
36
- const response = yield fetch(genesisEndpoint, {
37
- method: 'GET',
38
- });
39
- const json = yield response.json();
40
- if ((_a = json.data) === null || _a === void 0 ? void 0 : _a.genesis_validators_root) {
41
- return json.data.genesis_validators_root;
42
- }
43
- console.error('Invalid response structure from genesis endpoint', json);
44
- return null;
45
- }
46
- catch (e) {
47
- console.error(`Error fetching genesis validators root from ${genesisEndpoint}:`, e);
48
- const errorMessage = e instanceof Error ? e.message : String(e);
49
- throw new Error(`Failed to fetch genesis validators root: ${errorMessage}`);
50
- }
51
- });
52
- }