@obolnetwork/obol-sdk 2.2.4 → 2.3.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.2.4",
3
+ "version": "2.3.0",
4
4
  "description": "A package for creating Distributed Validators using the Obol API.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/obolnetwork/obol-sdk/issues"
@@ -370,5 +370,18 @@ class Client extends base_js_1.Base {
370
370
  return lock;
371
371
  });
372
372
  }
373
+ /**
374
+ * @param address - Operator address
375
+ * @returns {Promise<Incentives>} The matched incentives from DB
376
+ * @throws On not found if address not found.
377
+ */
378
+ getIncentivesByAddress(address) {
379
+ return __awaiter(this, void 0, void 0, function* () {
380
+ const incentives = yield this.request(`/${constants_js_1.DEFAULT_BASE_VERSION}/address/incentives/${address}`, {
381
+ method: 'GET',
382
+ });
383
+ return incentives;
384
+ });
385
+ }
373
386
  }
374
387
  exports.Client = Client;
@@ -31,6 +31,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
+ var _a, _b;
34
35
  Object.defineProperty(exports, "__esModule", { value: true });
35
36
  const ethers_1 = require("ethers");
36
37
  const index_1 = require("../src/index");
@@ -44,15 +45,14 @@ const termsAndConditions_1 = require("../src/verification/termsAndConditions");
44
45
  const utils = __importStar(require("../src/utils"));
45
46
  const splitsHelpers = __importStar(require("../src/splitHelpers"));
46
47
  jest.setTimeout(20000);
48
+ const mnemonic = (_b = (_a = ethers_1.ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
49
+ const privateKey = ethers_1.ethers.Wallet.fromPhrase(mnemonic).privateKey;
50
+ const provider = new ethers_1.JsonRpcProvider('https://ethereum-holesky.publicnode.com');
51
+ const wallet = new ethers_1.ethers.Wallet(privateKey, provider);
52
+ const mockSigner = wallet.connect(provider);
47
53
  /* eslint no-new: 0 */
48
54
  describe('Cluster Client', () => {
49
- var _a, _b;
50
55
  const mockConfigHash = '0x1f6c94e6c070393a68c1aa6073a21cb1fd57f0e14d2a475a2958990ab728c2fd';
51
- const mnemonic = (_b = (_a = ethers_1.ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
52
- const privateKey = ethers_1.ethers.Wallet.fromPhrase(mnemonic).privateKey;
53
- const provider = new ethers_1.JsonRpcProvider('https://ethereum-holesky.publicnode.com');
54
- const wallet = new ethers_1.ethers.Wallet(privateKey, provider);
55
- const mockSigner = wallet.connect(provider);
56
56
  const clientInstance = new index_1.Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
57
57
  test('createTermsAndConditions should return "successful authorization"', () => __awaiter(void 0, void 0, void 0, function* () {
58
58
  clientInstance['request'] = jest
@@ -117,12 +117,12 @@ describe('Cluster Client', () => {
117
117
  }
118
118
  }));
119
119
  test('getClusterdefinition should return cluster definition if config hash exist', () => __awaiter(void 0, void 0, void 0, function* () {
120
- var _c;
120
+ var _a;
121
121
  clientInstance['request'] = jest
122
122
  .fn()
123
123
  .mockReturnValue(Promise.resolve(fixtures_js_1.clusterLockV1X8.cluster_definition));
124
124
  const clusterDefinition = yield clientInstance.getClusterDefinition(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
125
- expect((_c = clusterDefinition.deposit_amounts) === null || _c === void 0 ? void 0 : _c.length).toEqual(fixtures_js_1.clusterLockV1X8.cluster_definition.deposit_amounts.length);
125
+ expect((_a = clusterDefinition.deposit_amounts) === null || _a === void 0 ? void 0 : _a.length).toEqual(fixtures_js_1.clusterLockV1X8.cluster_definition.deposit_amounts.length);
126
126
  expect(clusterDefinition.config_hash).toEqual(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
127
127
  }));
128
128
  test('getClusterLock should return lockFile if exist', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -233,9 +233,8 @@ describe('Cluster Client without a signer', () => {
233
233
  }));
234
234
  });
235
235
  describe('createObolRewardsSplit', () => {
236
- let clientInstance, clientInstanceWithourSigner, mockSplitRecipients, mockPrincipalRecipient, mockEtherAmount, mockSigner;
236
+ let clientInstance, clientInstanceWithourSigner, mockSplitRecipients, mockPrincipalRecipient, mockEtherAmount;
237
237
  beforeAll(() => {
238
- var _a, _b;
239
238
  jest
240
239
  .spyOn(utils, 'isContractAvailable')
241
240
  .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
@@ -248,11 +247,6 @@ describe('createObolRewardsSplit', () => {
248
247
  fee_recipient_address: '0xFeeRecipientAddress',
249
248
  });
250
249
  }));
251
- const mnemonic = (_b = (_a = ethers_1.ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
252
- const privateKey = ethers_1.ethers.Wallet.fromPhrase(mnemonic).privateKey;
253
- const provider = new ethers_1.JsonRpcProvider('https://ethereum-holesky.publicnode.com');
254
- const wallet = new ethers_1.ethers.Wallet(privateKey, provider);
255
- mockSigner = wallet.connect(provider);
256
250
  clientInstance = new index_1.Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
257
251
  clientInstanceWithourSigner = new index_1.Client({
258
252
  baseUrl: 'https://obol-api-dev.gcp.obol.tech',
@@ -330,9 +324,8 @@ describe('createObolRewardsSplit', () => {
330
324
  }));
331
325
  });
332
326
  describe('createObolTotalSplit', () => {
333
- let clientInstanceWithourSigner, mockSplitRecipients, mockSigner, clientInstance;
327
+ let clientInstanceWithourSigner, mockSplitRecipients, clientInstance;
334
328
  beforeAll(() => {
335
- var _a, _b;
336
329
  jest
337
330
  .spyOn(utils, 'isContractAvailable')
338
331
  .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
@@ -342,11 +335,6 @@ describe('createObolTotalSplit', () => {
342
335
  jest
343
336
  .spyOn(splitsHelpers, 'deploySplitterContract')
344
337
  .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xSplitterAddress'); }));
345
- const mnemonic = (_b = (_a = ethers_1.ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
346
- const privateKey = ethers_1.ethers.Wallet.fromPhrase(mnemonic).privateKey;
347
- const provider = new ethers_1.JsonRpcProvider('https://ethereum-holesky.publicnode.com');
348
- const wallet = new ethers_1.ethers.Wallet(privateKey, provider);
349
- mockSigner = wallet.connect(provider);
350
338
  clientInstance = new index_1.Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
351
339
  clientInstanceWithourSigner = new index_1.Client({
352
340
  baseUrl: 'https://obol-api-dev.gcp.obol.tech',
@@ -423,3 +411,47 @@ describe('createObolTotalSplit', () => {
423
411
  });
424
412
  }));
425
413
  });
414
+ describe('getIncentivesByAddress', () => {
415
+ let clientInstance;
416
+ beforeAll(() => {
417
+ jest
418
+ .spyOn(utils, 'isContractAvailable')
419
+ .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
420
+ jest
421
+ .spyOn(splitsHelpers, 'predictSplitterAddress')
422
+ .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xPredictedAddress'); }));
423
+ jest
424
+ .spyOn(splitsHelpers, 'deploySplitterContract')
425
+ .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xSplitterAddress'); }));
426
+ clientInstance = new index_1.Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
427
+ });
428
+ test('should return incentives for a valid address', () => __awaiter(void 0, void 0, void 0, function* () {
429
+ const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
430
+ const mockIncentives = {
431
+ operator_address: '0x8c00157cae72c4ed6a1f8bfb60205601f0252e26',
432
+ amount: '100',
433
+ index: 1,
434
+ merkle_proof: ['hash1', 'hash2'],
435
+ contract_address: '0xContract',
436
+ };
437
+ clientInstance['request'] = jest
438
+ .fn()
439
+ .mockReturnValue(Promise.resolve(mockIncentives));
440
+ const incentives = yield clientInstance.getIncentivesByAddress(mockAddress);
441
+ expect(incentives).toEqual(mockIncentives);
442
+ }));
443
+ test('should throw an error if address is not found', () => __awaiter(void 0, void 0, void 0, function* () {
444
+ const invalidAddress = '0x0000000000000000000000000000000000000000';
445
+ clientInstance['request'] = jest
446
+ .fn()
447
+ .mockRejectedValue(new Error('Not found'));
448
+ yield expect(clientInstance.getIncentivesByAddress(invalidAddress)).rejects.toThrow('Not found');
449
+ }));
450
+ test('should throw an error if request fails', () => __awaiter(void 0, void 0, void 0, function* () {
451
+ const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
452
+ clientInstance['request'] = jest
453
+ .fn()
454
+ .mockRejectedValue(new Error('Network error'));
455
+ yield expect(clientInstance.getIncentivesByAddress(mockAddress)).rejects.toThrow('Network error');
456
+ }));
457
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.2.4",
3
+ "version": "2.3.0",
4
4
  "description": "A package for creating Distributed Validators using the Obol API.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/obolnetwork/obol-sdk/issues"
@@ -353,4 +353,17 @@ export class Client extends Base {
353
353
  return lock;
354
354
  });
355
355
  }
356
+ /**
357
+ * @param address - Operator address
358
+ * @returns {Promise<Incentives>} The matched incentives from DB
359
+ * @throws On not found if address not found.
360
+ */
361
+ getIncentivesByAddress(address) {
362
+ return __awaiter(this, void 0, void 0, function* () {
363
+ const incentives = yield this.request(`/${DEFAULT_BASE_VERSION}/address/incentives/${address}`, {
364
+ method: 'GET',
365
+ });
366
+ return incentives;
367
+ });
368
+ }
356
369
  }
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ var _a, _b;
10
11
  import { ethers, JsonRpcProvider } from 'ethers';
11
12
  import { Client, validateClusterLock } from '../src/index';
12
13
  import { clusterConfigV1X7, clusterConfigV1X8, clusterLockV1X10, clusterLockV1X6, clusterLockV1X7, clusterLockV1X8, clusterLockWithCompoundingWithdrawals, clusterLockWithSafe, nullDepositAmountsClusterLockV1X8, } from './fixtures.js';
@@ -19,15 +20,14 @@ import { hashTermsAndConditions } from '../src/verification/termsAndConditions';
19
20
  import * as utils from '../src/utils';
20
21
  import * as splitsHelpers from '../src/splitHelpers';
21
22
  jest.setTimeout(20000);
23
+ const mnemonic = (_b = (_a = ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
24
+ const privateKey = ethers.Wallet.fromPhrase(mnemonic).privateKey;
25
+ const provider = new JsonRpcProvider('https://ethereum-holesky.publicnode.com');
26
+ const wallet = new ethers.Wallet(privateKey, provider);
27
+ const mockSigner = wallet.connect(provider);
22
28
  /* eslint no-new: 0 */
23
29
  describe('Cluster Client', () => {
24
- var _a, _b;
25
30
  const mockConfigHash = '0x1f6c94e6c070393a68c1aa6073a21cb1fd57f0e14d2a475a2958990ab728c2fd';
26
- const mnemonic = (_b = (_a = ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
27
- const privateKey = ethers.Wallet.fromPhrase(mnemonic).privateKey;
28
- const provider = new JsonRpcProvider('https://ethereum-holesky.publicnode.com');
29
- const wallet = new ethers.Wallet(privateKey, provider);
30
- const mockSigner = wallet.connect(provider);
31
31
  const clientInstance = new Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
32
32
  test('createTermsAndConditions should return "successful authorization"', () => __awaiter(void 0, void 0, void 0, function* () {
33
33
  clientInstance['request'] = jest
@@ -92,12 +92,12 @@ describe('Cluster Client', () => {
92
92
  }
93
93
  }));
94
94
  test('getClusterdefinition should return cluster definition if config hash exist', () => __awaiter(void 0, void 0, void 0, function* () {
95
- var _c;
95
+ var _a;
96
96
  clientInstance['request'] = jest
97
97
  .fn()
98
98
  .mockReturnValue(Promise.resolve(clusterLockV1X8.cluster_definition));
99
99
  const clusterDefinition = yield clientInstance.getClusterDefinition(clusterLockV1X8.cluster_definition.config_hash);
100
- expect((_c = clusterDefinition.deposit_amounts) === null || _c === void 0 ? void 0 : _c.length).toEqual(clusterLockV1X8.cluster_definition.deposit_amounts.length);
100
+ expect((_a = clusterDefinition.deposit_amounts) === null || _a === void 0 ? void 0 : _a.length).toEqual(clusterLockV1X8.cluster_definition.deposit_amounts.length);
101
101
  expect(clusterDefinition.config_hash).toEqual(clusterLockV1X8.cluster_definition.config_hash);
102
102
  }));
103
103
  test('getClusterLock should return lockFile if exist', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -208,9 +208,8 @@ describe('Cluster Client without a signer', () => {
208
208
  }));
209
209
  });
210
210
  describe('createObolRewardsSplit', () => {
211
- let clientInstance, clientInstanceWithourSigner, mockSplitRecipients, mockPrincipalRecipient, mockEtherAmount, mockSigner;
211
+ let clientInstance, clientInstanceWithourSigner, mockSplitRecipients, mockPrincipalRecipient, mockEtherAmount;
212
212
  beforeAll(() => {
213
- var _a, _b;
214
213
  jest
215
214
  .spyOn(utils, 'isContractAvailable')
216
215
  .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
@@ -223,11 +222,6 @@ describe('createObolRewardsSplit', () => {
223
222
  fee_recipient_address: '0xFeeRecipientAddress',
224
223
  });
225
224
  }));
226
- const mnemonic = (_b = (_a = ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
227
- const privateKey = ethers.Wallet.fromPhrase(mnemonic).privateKey;
228
- const provider = new JsonRpcProvider('https://ethereum-holesky.publicnode.com');
229
- const wallet = new ethers.Wallet(privateKey, provider);
230
- mockSigner = wallet.connect(provider);
231
225
  clientInstance = new Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
232
226
  clientInstanceWithourSigner = new Client({
233
227
  baseUrl: 'https://obol-api-dev.gcp.obol.tech',
@@ -305,9 +299,8 @@ describe('createObolRewardsSplit', () => {
305
299
  }));
306
300
  });
307
301
  describe('createObolTotalSplit', () => {
308
- let clientInstanceWithourSigner, mockSplitRecipients, mockSigner, clientInstance;
302
+ let clientInstanceWithourSigner, mockSplitRecipients, clientInstance;
309
303
  beforeAll(() => {
310
- var _a, _b;
311
304
  jest
312
305
  .spyOn(utils, 'isContractAvailable')
313
306
  .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
@@ -317,11 +310,6 @@ describe('createObolTotalSplit', () => {
317
310
  jest
318
311
  .spyOn(splitsHelpers, 'deploySplitterContract')
319
312
  .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xSplitterAddress'); }));
320
- const mnemonic = (_b = (_a = ethers.Wallet.createRandom().mnemonic) === null || _a === void 0 ? void 0 : _a.phrase) !== null && _b !== void 0 ? _b : '';
321
- const privateKey = ethers.Wallet.fromPhrase(mnemonic).privateKey;
322
- const provider = new JsonRpcProvider('https://ethereum-holesky.publicnode.com');
323
- const wallet = new ethers.Wallet(privateKey, provider);
324
- mockSigner = wallet.connect(provider);
325
313
  clientInstance = new Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
326
314
  clientInstanceWithourSigner = new Client({
327
315
  baseUrl: 'https://obol-api-dev.gcp.obol.tech',
@@ -398,3 +386,47 @@ describe('createObolTotalSplit', () => {
398
386
  });
399
387
  }));
400
388
  });
389
+ describe('getIncentivesByAddress', () => {
390
+ let clientInstance;
391
+ beforeAll(() => {
392
+ jest
393
+ .spyOn(utils, 'isContractAvailable')
394
+ .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve(true); }));
395
+ jest
396
+ .spyOn(splitsHelpers, 'predictSplitterAddress')
397
+ .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xPredictedAddress'); }));
398
+ jest
399
+ .spyOn(splitsHelpers, 'deploySplitterContract')
400
+ .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.resolve('0xSplitterAddress'); }));
401
+ clientInstance = new Client({ baseUrl: 'https://obol-api-dev.gcp.obol.tech', chainId: 17000 }, mockSigner);
402
+ });
403
+ test('should return incentives for a valid address', () => __awaiter(void 0, void 0, void 0, function* () {
404
+ const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
405
+ const mockIncentives = {
406
+ operator_address: '0x8c00157cae72c4ed6a1f8bfb60205601f0252e26',
407
+ amount: '100',
408
+ index: 1,
409
+ merkle_proof: ['hash1', 'hash2'],
410
+ contract_address: '0xContract',
411
+ };
412
+ clientInstance['request'] = jest
413
+ .fn()
414
+ .mockReturnValue(Promise.resolve(mockIncentives));
415
+ const incentives = yield clientInstance.getIncentivesByAddress(mockAddress);
416
+ expect(incentives).toEqual(mockIncentives);
417
+ }));
418
+ test('should throw an error if address is not found', () => __awaiter(void 0, void 0, void 0, function* () {
419
+ const invalidAddress = '0x0000000000000000000000000000000000000000';
420
+ clientInstance['request'] = jest
421
+ .fn()
422
+ .mockRejectedValue(new Error('Not found'));
423
+ yield expect(clientInstance.getIncentivesByAddress(invalidAddress)).rejects.toThrow('Not found');
424
+ }));
425
+ test('should throw an error if request fails', () => __awaiter(void 0, void 0, void 0, function* () {
426
+ const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
427
+ clientInstance['request'] = jest
428
+ .fn()
429
+ .mockRejectedValue(new Error('Network error'));
430
+ yield expect(clientInstance.getIncentivesByAddress(mockAddress)).rejects.toThrow('Network error');
431
+ }));
432
+ });
@@ -1,6 +1,6 @@
1
1
  import { type Signer } from 'ethers';
2
2
  import { Base } from './base.js';
3
- import { type RewardsSplitPayload, type ClusterDefinition, type ClusterLock, type ClusterPayload, type OperatorPayload, type TotalSplitPayload, type ClusterValidator, type ETH_ADDRESS, type OWRTranches } from './types.js';
3
+ import { type RewardsSplitPayload, type ClusterDefinition, type ClusterLock, type ClusterPayload, type OperatorPayload, type TotalSplitPayload, type ClusterValidator, type ETH_ADDRESS, type OWRTranches, type Incentives } from './types.js';
4
4
  export * from './types.js';
5
5
  export * from './services.js';
6
6
  export * from './verification/signature-validator.js';
@@ -112,4 +112,10 @@ export declare class Client extends Base {
112
112
  * [getObolClusterLock](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L89)
113
113
  */
114
114
  getClusterLock(configHash: string): Promise<ClusterLock>;
115
+ /**
116
+ * @param address - Operator address
117
+ * @returns {Promise<Incentives>} The matched incentives from DB
118
+ * @throws On not found if address not found.
119
+ */
120
+ getIncentivesByAddress(address: string): Promise<Incentives>;
115
121
  }
@@ -211,6 +211,21 @@ export type ClusterLock = {
211
211
  /** Node Signature for the lock hash by the node secp256k1 key. */
212
212
  node_signatures?: string[];
213
213
  };
214
+ /**
215
+ * Incentives
216
+ */
217
+ export type Incentives = {
218
+ /** Operator Address. */
219
+ operator_address: string;
220
+ /** The amount the recipient is entitled to. */
221
+ amount: string;
222
+ /** The recipient’s index in the Merkle tree. */
223
+ index: number;
224
+ /** The Merkle proof (an array of hashes) generated for the recipient. */
225
+ merkle_proof: string[];
226
+ /** The MerkleDistributor contract address. */
227
+ contract_address: string;
228
+ };
214
229
  /**
215
230
  * String expected to be Ethereum Address
216
231
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.2.4",
3
+ "version": "2.3.0",
4
4
  "description": "A package for creating Distributed Validators using the Obol API.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/obolnetwork/obol-sdk/issues"
package/src/index.ts CHANGED
@@ -30,6 +30,7 @@ import {
30
30
  type ClusterValidator,
31
31
  type ETH_ADDRESS,
32
32
  type OWRTranches,
33
+ type Incentives,
33
34
  } from './types.js';
34
35
  import { clusterConfigOrDefinitionHash } from './verification/common.js';
35
36
  import { validatePayload } from './ajv.js';
@@ -520,4 +521,19 @@ export class Client extends Base {
520
521
  );
521
522
  return lock;
522
523
  }
524
+
525
+ /**
526
+ * @param address - Operator address
527
+ * @returns {Promise<Incentives>} The matched incentives from DB
528
+ * @throws On not found if address not found.
529
+ */
530
+ async getIncentivesByAddress(address: string): Promise<Incentives> {
531
+ const incentives: Incentives = await this.request(
532
+ `/${DEFAULT_BASE_VERSION}/address/incentives/${address}`,
533
+ {
534
+ method: 'GET',
535
+ },
536
+ );
537
+ return incentives;
538
+ }
523
539
  }
package/src/types.ts CHANGED
@@ -293,6 +293,26 @@ export type ClusterLock = {
293
293
  node_signatures?: string[];
294
294
  };
295
295
 
296
+ /**
297
+ * Incentives
298
+ */
299
+ export type Incentives = {
300
+ /** Operator Address. */
301
+ operator_address: string;
302
+
303
+ /** The amount the recipient is entitled to. */
304
+ amount: string;
305
+
306
+ /** The recipient’s index in the Merkle tree. */
307
+ index: number;
308
+
309
+ /** The Merkle proof (an array of hashes) generated for the recipient. */
310
+ merkle_proof: string[];
311
+
312
+ /** The MerkleDistributor contract address. */
313
+ contract_address: string;
314
+ };
315
+
296
316
  /**
297
317
  * String expected to be Ethereum Address
298
318
  */