@obolnetwork/obol-sdk 2.4.4 → 2.4.5

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.4.4",
3
+ "version": "2.4.5",
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"
@@ -23,7 +23,8 @@
23
23
  "lint": "eslint \"{src,test}/**/*.{js,ts}\" --fix",
24
24
  "lint-ci": "eslint \"{src,test}/**/*.{js,ts}\"",
25
25
  "prettier-ci": "prettier --check \"{src,test}/**/*.{js,ts}\"",
26
- "prettier": "prettier --write \"{src,test}/**/*.{js,ts}\""
26
+ "prettier": "prettier --write \"{src,test}/**/*.{js,ts}\"",
27
+ "docs": "typedoc"
27
28
  },
28
29
  "main": "./dist/cjs/src/index.js",
29
30
  "module": "./dist/esm/src/index.js",
@@ -79,8 +80,8 @@
79
80
  "release-it": "^17.2.1",
80
81
  "ts-jest": "^28.0.8",
81
82
  "tsup": "^6.7.0",
82
- "typedoc": "^0.25.7",
83
- "typedoc-plugin-markdown": "^4.0.0-next.50",
83
+ "typedoc": "^0.28.0",
84
+ "typedoc-plugin-markdown": "^4.5.2",
84
85
  "typescript": "~5.3.3"
85
86
  },
86
87
  "engines": {
@@ -14,6 +14,14 @@ const utils_1 = require("./utils");
14
14
  const types_1 = require("./types");
15
15
  const incentiveHelpers_1 = require("./incentiveHelpers");
16
16
  const constants_1 = require("./constants");
17
+ /**
18
+ * Incentives can be used for fetching and claiming Obol incentives.
19
+ * @class
20
+ * @internal Access it through Client.incentives.
21
+ * @example
22
+ * const obolClient = new Client(config);
23
+ * await obolClient.incentives.claimIncentives(address);
24
+ */
17
25
  class Incentives {
18
26
  constructor(signer, chainId, request, provider) {
19
27
  this.signer = signer;
@@ -22,16 +30,23 @@ class Incentives {
22
30
  this.provider = provider;
23
31
  }
24
32
  /**
25
- * Claims obol incentives from a Merkle Distributor contract using just an address.
26
- * The method automatically fetches incentives data and checks if already claimed.
33
+ * Claims Obol incentives from a Merkle Distributor contract using an address.
34
+ *
35
+ * This method automatically fetches incentive data and verifies whether the incentives have already been claimed.
36
+ * If `txHash` is `null`, it indicates that the incentives were already claimed.
37
+ *
38
+ * Note: This method is not yet enabled and will throw an error if called.
27
39
  *
28
40
  * @remarks
29
41
  * **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
30
42
  * and not pushed to version control.
31
43
  *
32
44
  * @param {string} address - The address to claim incentives for
33
- * @returns {Promise<{ txHash: string } | { alreadyClaimed: true }>} The transaction hash or already claimed status
45
+ * @returns {Promise<ClaimIncentivesResponse>} The transaction hash or already claimed status
34
46
  * @throws Will throw an error if the incentives data is not found or the claim fails
47
+ *
48
+ * An example of how to use claimIncentives:
49
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L281)
35
50
  */
36
51
  claimIncentives(address) {
37
52
  return __awaiter(this, void 0, void 0, function* () {
@@ -49,7 +64,7 @@ class Incentives {
49
64
  }
50
65
  const claimed = yield this.isClaimed(incentivesData.contract_address, incentivesData.index);
51
66
  if (claimed) {
52
- return { alreadyClaimed: true };
67
+ return { txHash: null };
53
68
  }
54
69
  const { txHash } = yield (0, incentiveHelpers_1.claimIncentivesFromMerkleDistributor)({
55
70
  signer: this.signer,
@@ -74,6 +89,9 @@ class Incentives {
74
89
  * @param {ETH_ADDRESS} index - operator index in merkle tree
75
90
  * @returns {Promise<boolean>} true if incentives are already claime
76
91
  *
92
+ *
93
+ * An example of how to use isClaimed:
94
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L266)
77
95
  */
78
96
  isClaimed(contractAddress, index) {
79
97
  return __awaiter(this, void 0, void 0, function* () {
@@ -84,6 +102,9 @@ class Incentives {
84
102
  * @param address - Operator address
85
103
  * @returns {Promise<IncentivesType>} The matched incentives from DB
86
104
  * @throws On not found if address not found.
105
+ *
106
+ * An example of how to use getIncentivesByAddress:
107
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L250)
87
108
  */
88
109
  getIncentivesByAddress(address) {
89
110
  return __awaiter(this, void 0, void 0, function* () {
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  });
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Client = void 0;
26
+ exports.Client = exports.Incentives = void 0;
27
27
  const ethers_1 = require("ethers");
28
28
  const uuid_1 = require("uuid");
29
29
  const base_js_1 = require("./base.js");
@@ -39,6 +39,8 @@ __exportStar(require("./types.js"), exports);
39
39
  __exportStar(require("./services.js"), exports);
40
40
  __exportStar(require("./verification/signature-validator.js"), exports);
41
41
  __exportStar(require("./verification/common.js"), exports);
42
+ var incentives_js_2 = require("./incentives.js");
43
+ Object.defineProperty(exports, "Incentives", { enumerable: true, get: function () { return incentives_js_2.Incentives; } });
42
44
  /**
43
45
  * Obol sdk Client can be used for creating, managing and activating distributed validators.
44
46
  */
@@ -19,20 +19,11 @@ var FORK_MAPPING;
19
19
  /** Hoodi Chain. */
20
20
  FORK_MAPPING[FORK_MAPPING["0x10000910"] = 560048] = "0x10000910";
21
21
  })(FORK_MAPPING || (exports.FORK_MAPPING = FORK_MAPPING = {}));
22
- /**
23
- * Permitted Chain Names
24
- */
25
22
  exports.FORK_NAMES = {
26
- /** Mainnet. */
27
23
  [FORK_MAPPING['0x00000000']]: 'mainnet',
28
- /** Goerli/Prater. */
29
24
  [FORK_MAPPING['0x00001020']]: 'goerli',
30
- /** Gnosis Chain. */
31
25
  [FORK_MAPPING['0x00000064']]: 'gnosis',
32
- /** Holesky. */
33
26
  [FORK_MAPPING['0x01017000']]: 'holesky',
34
- /** Sepolia. */
35
27
  [FORK_MAPPING['0x90000069']]: 'sepolia',
36
- /** Hoodi. */
37
28
  [FORK_MAPPING['0x10000910']]: 'hoodi',
38
29
  };
@@ -104,13 +104,13 @@ global.fetch = globals_1.jest.fn();
104
104
  merkleProof: mockIncentivesData.merkle_proof,
105
105
  });
106
106
  }));
107
- (0, globals_1.test)('claimIncentives should return alreadyClaimed when incentives are already claimed', () => __awaiter(void 0, void 0, void 0, function* () {
107
+ (0, globals_1.test)('claimIncentives should return txHash as null when incentives are already claimed', () => __awaiter(void 0, void 0, void 0, function* () {
108
108
  globals_1.jest
109
109
  .spyOn(clientInstance.incentives, 'getIncentivesByAddress')
110
110
  .mockResolvedValue(mockIncentivesData);
111
111
  globals_1.jest.spyOn(clientInstance.incentives, 'isClaimed').mockResolvedValue(true);
112
112
  const result = yield clientInstance.incentives.claimIncentives(mockIncentivesData.operator_address);
113
- (0, globals_1.expect)(result).toEqual({ alreadyClaimed: true });
113
+ (0, globals_1.expect)(result).toEqual({ txHash: null });
114
114
  (0, globals_1.expect)(incentivesHelpers.claimIncentivesFromMerkleDistributor).not.toHaveBeenCalled();
115
115
  }));
116
116
  (0, globals_1.test)('claimIncentives should throw an error if no incentives found for address', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
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"
@@ -23,7 +23,8 @@
23
23
  "lint": "eslint \"{src,test}/**/*.{js,ts}\" --fix",
24
24
  "lint-ci": "eslint \"{src,test}/**/*.{js,ts}\"",
25
25
  "prettier-ci": "prettier --check \"{src,test}/**/*.{js,ts}\"",
26
- "prettier": "prettier --write \"{src,test}/**/*.{js,ts}\""
26
+ "prettier": "prettier --write \"{src,test}/**/*.{js,ts}\"",
27
+ "docs": "typedoc"
27
28
  },
28
29
  "main": "./dist/cjs/src/index.js",
29
30
  "module": "./dist/esm/src/index.js",
@@ -79,8 +80,8 @@
79
80
  "release-it": "^17.2.1",
80
81
  "ts-jest": "^28.0.8",
81
82
  "tsup": "^6.7.0",
82
- "typedoc": "^0.25.7",
83
- "typedoc-plugin-markdown": "^4.0.0-next.50",
83
+ "typedoc": "^0.28.0",
84
+ "typedoc-plugin-markdown": "^4.5.2",
84
85
  "typescript": "~5.3.3"
85
86
  },
86
87
  "engines": {
@@ -7,7 +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
- import { Contract, } from 'ethers';
10
+ import { Contract } from 'ethers';
11
11
  import { MerkleDistributorABI } from './abi/MerkleDistributorWithDeadline';
12
12
  import { getProvider } from './utils';
13
13
  export const claimIncentivesFromMerkleDistributor = (incentivesData) => __awaiter(void 0, void 0, void 0, function* () {
@@ -11,6 +11,14 @@ import { isContractAvailable } from './utils';
11
11
  import { FORK_NAMES, } from './types';
12
12
  import { claimIncentivesFromMerkleDistributor, isClaimedFromMerkleDistributor, } from './incentiveHelpers';
13
13
  import { DEFAULT_BASE_VERSION } from './constants';
14
+ /**
15
+ * Incentives can be used for fetching and claiming Obol incentives.
16
+ * @class
17
+ * @internal Access it through Client.incentives.
18
+ * @example
19
+ * const obolClient = new Client(config);
20
+ * await obolClient.incentives.claimIncentives(address);
21
+ */
14
22
  export class Incentives {
15
23
  constructor(signer, chainId, request, provider) {
16
24
  this.signer = signer;
@@ -19,16 +27,23 @@ export class Incentives {
19
27
  this.provider = provider;
20
28
  }
21
29
  /**
22
- * Claims obol incentives from a Merkle Distributor contract using just an address.
23
- * The method automatically fetches incentives data and checks if already claimed.
30
+ * Claims Obol incentives from a Merkle Distributor contract using an address.
31
+ *
32
+ * This method automatically fetches incentive data and verifies whether the incentives have already been claimed.
33
+ * If `txHash` is `null`, it indicates that the incentives were already claimed.
34
+ *
35
+ * Note: This method is not yet enabled and will throw an error if called.
24
36
  *
25
37
  * @remarks
26
38
  * **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
27
39
  * and not pushed to version control.
28
40
  *
29
41
  * @param {string} address - The address to claim incentives for
30
- * @returns {Promise<{ txHash: string } | { alreadyClaimed: true }>} The transaction hash or already claimed status
42
+ * @returns {Promise<ClaimIncentivesResponse>} The transaction hash or already claimed status
31
43
  * @throws Will throw an error if the incentives data is not found or the claim fails
44
+ *
45
+ * An example of how to use claimIncentives:
46
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L281)
32
47
  */
33
48
  claimIncentives(address) {
34
49
  return __awaiter(this, void 0, void 0, function* () {
@@ -46,7 +61,7 @@ export class Incentives {
46
61
  }
47
62
  const claimed = yield this.isClaimed(incentivesData.contract_address, incentivesData.index);
48
63
  if (claimed) {
49
- return { alreadyClaimed: true };
64
+ return { txHash: null };
50
65
  }
51
66
  const { txHash } = yield claimIncentivesFromMerkleDistributor({
52
67
  signer: this.signer,
@@ -71,6 +86,9 @@ export class Incentives {
71
86
  * @param {ETH_ADDRESS} index - operator index in merkle tree
72
87
  * @returns {Promise<boolean>} true if incentives are already claime
73
88
  *
89
+ *
90
+ * An example of how to use isClaimed:
91
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L266)
74
92
  */
75
93
  isClaimed(contractAddress, index) {
76
94
  return __awaiter(this, void 0, void 0, function* () {
@@ -81,6 +99,9 @@ export class Incentives {
81
99
  * @param address - Operator address
82
100
  * @returns {Promise<IncentivesType>} The matched incentives from DB
83
101
  * @throws On not found if address not found.
102
+ *
103
+ * An example of how to use getIncentivesByAddress:
104
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L250)
84
105
  */
85
106
  getIncentivesByAddress(address) {
86
107
  return __awaiter(this, void 0, void 0, function* () {
@@ -7,7 +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
- import { ZeroAddress, } from 'ethers';
10
+ import { ZeroAddress } from 'ethers';
11
11
  import { v4 as uuidv4 } from 'uuid';
12
12
  import { Base } from './base.js';
13
13
  import { CONFLICT_ERROR_MSG, CreatorConfigHashSigningTypes, Domain, DKG_ALGORITHM, CONFIG_VERSION, OperatorConfigHashSigningTypes, EnrSigningTypes, TERMS_AND_CONDITIONS_VERSION, TermsAndConditionsSigningTypes, DEFAULT_BASE_VERSION, TERMS_AND_CONDITIONS_HASH, AVAILABLE_SPLITTER_CHAINS, CHAIN_CONFIGURATION, DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT, DEFAULT_RETROACTIVE_FUNDING_TOTAL_SPLIT, OBOL_SDK_EMAIL, } from './constants.js';
@@ -22,6 +22,7 @@ export * from './types.js';
22
22
  export * from './services.js';
23
23
  export * from './verification/signature-validator.js';
24
24
  export * from './verification/common.js';
25
+ export { Incentives } from './incentives.js';
25
26
  /**
26
27
  * Obol sdk Client can be used for creating, managing and activating distributed validators.
27
28
  */
@@ -7,7 +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
- import { Contract, Interface, parseEther, ZeroAddress, } from 'ethers';
10
+ import { Contract, Interface, parseEther, ZeroAddress } from 'ethers';
11
11
  import { OWRContract, OWRFactoryContract } from './abi/OWR';
12
12
  import { splitMainEthereumAbi } from './abi/SplitMain';
13
13
  import { MultiCallContract } from './abi/Multicall';
@@ -16,20 +16,11 @@ export var FORK_MAPPING;
16
16
  /** Hoodi Chain. */
17
17
  FORK_MAPPING[FORK_MAPPING["0x10000910"] = 560048] = "0x10000910";
18
18
  })(FORK_MAPPING || (FORK_MAPPING = {}));
19
- /**
20
- * Permitted Chain Names
21
- */
22
19
  export const FORK_NAMES = {
23
- /** Mainnet. */
24
20
  [FORK_MAPPING['0x00000000']]: 'mainnet',
25
- /** Goerli/Prater. */
26
21
  [FORK_MAPPING['0x00001020']]: 'goerli',
27
- /** Gnosis Chain. */
28
22
  [FORK_MAPPING['0x00000064']]: 'gnosis',
29
- /** Holesky. */
30
23
  [FORK_MAPPING['0x01017000']]: 'holesky',
31
- /** Sepolia. */
32
24
  [FORK_MAPPING['0x90000069']]: 'sepolia',
33
- /** Hoodi. */
34
25
  [FORK_MAPPING['0x10000910']]: 'hoodi',
35
26
  };
@@ -79,13 +79,13 @@ describe('Client.incentives', () => {
79
79
  merkleProof: mockIncentivesData.merkle_proof,
80
80
  });
81
81
  }));
82
- test('claimIncentives should return alreadyClaimed when incentives are already claimed', () => __awaiter(void 0, void 0, void 0, function* () {
82
+ test('claimIncentives should return txHash as null when incentives are already claimed', () => __awaiter(void 0, void 0, void 0, function* () {
83
83
  jest
84
84
  .spyOn(clientInstance.incentives, 'getIncentivesByAddress')
85
85
  .mockResolvedValue(mockIncentivesData);
86
86
  jest.spyOn(clientInstance.incentives, 'isClaimed').mockResolvedValue(true);
87
87
  const result = yield clientInstance.incentives.claimIncentives(mockIncentivesData.operator_address);
88
- expect(result).toEqual({ alreadyClaimed: true });
88
+ expect(result).toEqual({ txHash: null });
89
89
  expect(incentivesHelpers.claimIncentivesFromMerkleDistributor).not.toHaveBeenCalled();
90
90
  }));
91
91
  test('claimIncentives should throw an error if no incentives found for address', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,7 +1,6 @@
1
- import { type ETH_ADDRESS } from './types';
2
- import { type JsonRpcApiProvider, type JsonRpcProvider, type Provider, type Signer } from 'ethers';
1
+ import { type ProviderType, type SignerType, type ETH_ADDRESS } from './types';
3
2
  export declare const claimIncentivesFromMerkleDistributor: (incentivesData: {
4
- signer: Signer;
3
+ signer: SignerType;
5
4
  contractAddress: ETH_ADDRESS;
6
5
  index: number;
7
6
  operatorAddress: ETH_ADDRESS;
@@ -10,4 +9,4 @@ export declare const claimIncentivesFromMerkleDistributor: (incentivesData: {
10
9
  }) => Promise<{
11
10
  txHash: string;
12
11
  }>;
13
- export declare const isClaimedFromMerkleDistributor: (chainId: number, contractAddress: ETH_ADDRESS, index: number, provider: Provider | JsonRpcProvider | JsonRpcApiProvider | undefined | null) => Promise<boolean>;
12
+ export declare const isClaimedFromMerkleDistributor: (chainId: number, contractAddress: ETH_ADDRESS, index: number, provider: ProviderType | undefined | null) => Promise<boolean>;
@@ -1,28 +1,38 @@
1
- import type { JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, Provider, Signer } from 'ethers';
2
- import { type Incentives as IncentivesType, type ETH_ADDRESS } from './types';
1
+ import { type Incentives as IncentivesType, type ETH_ADDRESS, type ProviderType, type SignerType, type ClaimIncentivesResponse } from './types';
2
+ /**
3
+ * Incentives can be used for fetching and claiming Obol incentives.
4
+ * @class
5
+ * @internal Access it through Client.incentives.
6
+ * @example
7
+ * const obolClient = new Client(config);
8
+ * await obolClient.incentives.claimIncentives(address);
9
+ */
3
10
  export declare class Incentives {
4
11
  private readonly signer;
5
12
  readonly chainId: number;
6
13
  private readonly request;
7
- readonly provider: Provider | JsonRpcProvider | JsonRpcApiProvider | undefined | null;
8
- constructor(signer: Signer | JsonRpcSigner | undefined, chainId: number, request: (endpoint: string, options?: RequestInit) => Promise<any>, provider: Provider | JsonRpcProvider | JsonRpcApiProvider | undefined | null);
14
+ readonly provider: ProviderType | undefined | null;
15
+ constructor(signer: SignerType | undefined, chainId: number, request: (endpoint: string, options?: RequestInit) => Promise<any>, provider: ProviderType | undefined | null);
9
16
  /**
10
- * Claims obol incentives from a Merkle Distributor contract using just an address.
11
- * The method automatically fetches incentives data and checks if already claimed.
17
+ * Claims Obol incentives from a Merkle Distributor contract using an address.
18
+ *
19
+ * This method automatically fetches incentive data and verifies whether the incentives have already been claimed.
20
+ * If `txHash` is `null`, it indicates that the incentives were already claimed.
21
+ *
22
+ * Note: This method is not yet enabled and will throw an error if called.
12
23
  *
13
24
  * @remarks
14
25
  * **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
15
26
  * and not pushed to version control.
16
27
  *
17
28
  * @param {string} address - The address to claim incentives for
18
- * @returns {Promise<{ txHash: string } | { alreadyClaimed: true }>} The transaction hash or already claimed status
29
+ * @returns {Promise<ClaimIncentivesResponse>} The transaction hash or already claimed status
19
30
  * @throws Will throw an error if the incentives data is not found or the claim fails
31
+ *
32
+ * An example of how to use claimIncentives:
33
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L281)
20
34
  */
21
- claimIncentives(address: string): Promise<{
22
- txHash: string;
23
- } | {
24
- alreadyClaimed: true;
25
- }>;
35
+ claimIncentives(address: string): Promise<ClaimIncentivesResponse>;
26
36
  /**
27
37
  * Read isClaimed.
28
38
  *
@@ -30,12 +40,18 @@ export declare class Incentives {
30
40
  * @param {ETH_ADDRESS} index - operator index in merkle tree
31
41
  * @returns {Promise<boolean>} true if incentives are already claime
32
42
  *
43
+ *
44
+ * An example of how to use isClaimed:
45
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L266)
33
46
  */
34
47
  isClaimed(contractAddress: ETH_ADDRESS, index: number): Promise<boolean>;
35
48
  /**
36
49
  * @param address - Operator address
37
50
  * @returns {Promise<IncentivesType>} The matched incentives from DB
38
51
  * @throws On not found if address not found.
52
+ *
53
+ * An example of how to use getIncentivesByAddress:
54
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L250)
39
55
  */
40
56
  getIncentivesByAddress(address: string): Promise<IncentivesType>;
41
57
  }
@@ -1,18 +1,29 @@
1
- import { type Provider, type Signer, type JsonRpcSigner, type JsonRpcProvider, type JsonRpcApiProvider } from 'ethers';
2
1
  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';
2
+ import { type RewardsSplitPayload, type ClusterDefinition, type ClusterLock, type ClusterPayload, type OperatorPayload, type TotalSplitPayload, type ClusterValidator, type ETH_ADDRESS, type OWRTranches, type ProviderType, type SignerType } from './types.js';
4
3
  import { Incentives } from './incentives.js';
5
4
  export * from './types.js';
6
5
  export * from './services.js';
7
6
  export * from './verification/signature-validator.js';
8
7
  export * from './verification/common.js';
8
+ export { Incentives } from './incentives.js';
9
9
  /**
10
10
  * Obol sdk Client can be used for creating, managing and activating distributed validators.
11
11
  */
12
12
  export declare class Client extends Base {
13
+ /**
14
+ * The signer used for signing transactions.
15
+ */
13
16
  private readonly signer;
17
+ /**
18
+ * The incentives module, responsible for managing Obol tokens distribution.
19
+ * @type {Incentives}
20
+ */
14
21
  incentives: Incentives;
15
- provider: Provider | JsonRpcProvider | JsonRpcApiProvider | undefined | null;
22
+ /**
23
+ * The blockchain provider, used to interact with the network.
24
+ * It can be null, undefined, or a valid provider instance and defaults to the Signer provider if Signer is passed.
25
+ */
26
+ provider: ProviderType | undefined | null;
16
27
  /**
17
28
  * @param config - Client configurations
18
29
  * @param config.baseUrl - obol-api url
@@ -26,7 +37,7 @@ export declare class Client extends Base {
26
37
  constructor(config: {
27
38
  baseUrl?: string;
28
39
  chainId?: number;
29
- }, signer?: Signer | JsonRpcSigner, provider?: Provider | JsonRpcProvider);
40
+ }, signer?: SignerType, provider?: ProviderType);
30
41
  /**
31
42
  * Accepts Obol terms and conditions to be able to create or update data.
32
43
  * @returns {Promise<string>} terms and conditions acceptance success message.
@@ -1,5 +1,4 @@
1
- import { type OWRTranches, type ClusterValidator, type ETH_ADDRESS, type SplitRecipient } from './types';
2
- import { type Signer } from 'ethers';
1
+ import { type OWRTranches, type ClusterValidator, type ETH_ADDRESS, type SplitRecipient, type SignerType } from './types';
3
2
  type Call = {
4
3
  target: ETH_ADDRESS;
5
4
  callData: string;
@@ -21,7 +20,7 @@ export declare const formatSplitRecipients: (recipients: SplitRecipient[]) => {
21
20
  percentAllocations: number[];
22
21
  };
23
22
  export declare const predictSplitterAddress: ({ signer, accounts, percentAllocations, chainId, distributorFee, controllerAddress, }: {
24
- signer: Signer;
23
+ signer: SignerType;
25
24
  accounts: ETH_ADDRESS[];
26
25
  percentAllocations: number[];
27
26
  chainId: number;
@@ -29,7 +28,7 @@ export declare const predictSplitterAddress: ({ signer, accounts, percentAllocat
29
28
  controllerAddress: ETH_ADDRESS;
30
29
  }) => Promise<ETH_ADDRESS>;
31
30
  export declare const handleDeployOWRAndSplitter: ({ signer, isSplitterDeployed, predictedSplitterAddress, accounts, percentAllocations, etherAmount, principalRecipient, chainId, distributorFee, controllerAddress, recoveryAddress, }: {
32
- signer: Signer;
31
+ signer: SignerType;
33
32
  isSplitterDeployed: boolean;
34
33
  predictedSplitterAddress: ETH_ADDRESS;
35
34
  accounts: ETH_ADDRESS[];
@@ -42,7 +41,7 @@ export declare const handleDeployOWRAndSplitter: ({ signer, isSplitterDeployed,
42
41
  recoveryAddress: ETH_ADDRESS;
43
42
  }) => Promise<ClusterValidator>;
44
43
  export declare const deploySplitterContract: ({ signer, accounts, percentAllocations, chainId, distributorFee, controllerAddress, }: {
45
- signer: Signer;
44
+ signer: SignerType;
46
45
  accounts: ETH_ADDRESS[];
47
46
  percentAllocations: number[];
48
47
  chainId: number;
@@ -52,7 +51,7 @@ export declare const deploySplitterContract: ({ signer, accounts, percentAllocat
52
51
  export declare const deploySplitterAndOWRContracts: ({ owrArgs, splitterArgs, signer, chainId, }: {
53
52
  owrArgs: OWRArgs;
54
53
  splitterArgs: SplitArgs;
55
- signer: Signer;
54
+ signer: SignerType;
56
55
  chainId: number;
57
56
  }) => Promise<{
58
57
  owrAddress: ETH_ADDRESS;
@@ -60,7 +59,7 @@ export declare const deploySplitterAndOWRContracts: ({ owrArgs, splitterArgs, si
60
59
  }>;
61
60
  export declare const getOWRTranches: ({ owrAddress, signer, }: {
62
61
  owrAddress: ETH_ADDRESS;
63
- signer: Signer;
62
+ signer: SignerType;
64
63
  }) => Promise<OWRTranches>;
65
- export declare const multicall: (calls: Call[], signer: Signer, multicallAddress: string) => Promise<any>;
64
+ export declare const multicall: (calls: Call[], signer: SignerType, multicallAddress: string) => Promise<any>;
66
65
  export {};
@@ -1,3 +1,4 @@
1
+ import { type ethers, type JsonRpcApiProvider, type JsonRpcProvider, type JsonRpcSigner, type Provider, type Signer } from 'ethers';
1
2
  /**
2
3
  * Permitted ChainID's
3
4
  */
@@ -15,9 +16,6 @@ export declare enum FORK_MAPPING {
15
16
  /** Hoodi Chain. */
16
17
  '0x10000910' = 560048
17
18
  }
18
- /**
19
- * Permitted Chain Names
20
- */
21
19
  export declare const FORK_NAMES: Record<number, string>;
22
20
  /**
23
21
  * Node operator data
@@ -232,3 +230,17 @@ export type Incentives = {
232
230
  * String expected to be Ethereum Address
233
231
  */
234
232
  export type ETH_ADDRESS = string;
233
+ /**
234
+ * Provider Types
235
+ */
236
+ export type ProviderType = Provider | JsonRpcProvider | JsonRpcApiProvider | ethers.BrowserProvider;
237
+ /**
238
+ * Signer Types
239
+ */
240
+ export type SignerType = Signer | JsonRpcSigner;
241
+ /**
242
+ * claimIncentives Response
243
+ */
244
+ export type ClaimIncentivesResponse = {
245
+ txHash: string | null;
246
+ };
@@ -1,9 +1,9 @@
1
- import { ethers, type Provider } from 'ethers';
1
+ import { ethers } from 'ethers';
2
2
  import { DefinitionFlow } from './constants';
3
- import { type ClusterDefinition } from './types';
3
+ import { type ProviderType, type ClusterDefinition } from './types';
4
4
  export declare const hexWithout0x: (hex: string) => string;
5
5
  export declare const strToUint8Array: (str: string) => Uint8Array;
6
6
  export declare const definitionFlow: (clusterDefinition: ClusterDefinition) => DefinitionFlow | null;
7
- export declare const findDeployedBytecode: (contractAddress: string, provider: Provider) => Promise<string>;
8
- export declare const isContractAvailable: (contractAddress: string, provider: Provider, bytecode?: string) => Promise<boolean>;
9
- export declare const getProvider: (chainId: number) => ethers.Provider;
7
+ export declare const findDeployedBytecode: (contractAddress: string, provider: ProviderType) => Promise<string>;
8
+ export declare const isContractAvailable: (contractAddress: string, provider: ProviderType, bytecode?: string) => Promise<boolean>;
9
+ export declare const getProvider: (chainId: number) => ethers.JsonRpcProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
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"
@@ -23,7 +23,8 @@
23
23
  "lint": "eslint \"{src,test}/**/*.{js,ts}\" --fix",
24
24
  "lint-ci": "eslint \"{src,test}/**/*.{js,ts}\"",
25
25
  "prettier-ci": "prettier --check \"{src,test}/**/*.{js,ts}\"",
26
- "prettier": "prettier --write \"{src,test}/**/*.{js,ts}\""
26
+ "prettier": "prettier --write \"{src,test}/**/*.{js,ts}\"",
27
+ "docs": "typedoc"
27
28
  },
28
29
  "main": "./dist/cjs/src/index.js",
29
30
  "module": "./dist/esm/src/index.js",
@@ -79,8 +80,8 @@
79
80
  "release-it": "^17.2.1",
80
81
  "ts-jest": "^28.0.8",
81
82
  "tsup": "^6.7.0",
82
- "typedoc": "^0.25.7",
83
- "typedoc-plugin-markdown": "^4.0.0-next.50",
83
+ "typedoc": "^0.28.0",
84
+ "typedoc-plugin-markdown": "^4.5.2",
84
85
  "typescript": "~5.3.3"
85
86
  },
86
87
  "engines": {
@@ -1,16 +1,10 @@
1
- import { type ETH_ADDRESS } from './types';
2
- import {
3
- Contract,
4
- type JsonRpcApiProvider,
5
- type JsonRpcProvider,
6
- type Provider,
7
- type Signer,
8
- } from 'ethers';
1
+ import { type ProviderType, type SignerType, type ETH_ADDRESS } from './types';
2
+ import { Contract } from 'ethers';
9
3
  import { MerkleDistributorABI } from './abi/MerkleDistributorWithDeadline';
10
4
  import { getProvider } from './utils';
11
5
 
12
6
  export const claimIncentivesFromMerkleDistributor = async (incentivesData: {
13
- signer: Signer;
7
+ signer: SignerType;
14
8
  contractAddress: ETH_ADDRESS;
15
9
  index: number;
16
10
  operatorAddress: ETH_ADDRESS;
@@ -44,7 +38,7 @@ export const isClaimedFromMerkleDistributor = async (
44
38
  chainId: number,
45
39
  contractAddress: ETH_ADDRESS,
46
40
  index: number,
47
- provider: Provider | JsonRpcProvider | JsonRpcApiProvider | undefined | null,
41
+ provider: ProviderType | undefined | null,
48
42
  ): Promise<boolean> => {
49
43
  try {
50
44
  const clientProvider = provider ?? getProvider(chainId);
package/src/incentives.ts CHANGED
@@ -1,15 +1,11 @@
1
- import type {
2
- JsonRpcApiProvider,
3
- JsonRpcProvider,
4
- JsonRpcSigner,
5
- Provider,
6
- Signer,
7
- } from 'ethers';
8
1
  import { isContractAvailable } from './utils';
9
2
  import {
10
3
  type Incentives as IncentivesType,
11
4
  type ETH_ADDRESS,
12
5
  FORK_NAMES,
6
+ type ProviderType,
7
+ type SignerType,
8
+ type ClaimIncentivesResponse,
13
9
  } from './types';
14
10
  import {
15
11
  claimIncentivesFromMerkleDistributor,
@@ -17,31 +13,29 @@ import {
17
13
  } from './incentiveHelpers';
18
14
  import { DEFAULT_BASE_VERSION } from './constants';
19
15
 
16
+ /**
17
+ * Incentives can be used for fetching and claiming Obol incentives.
18
+ * @class
19
+ * @internal Access it through Client.incentives.
20
+ * @example
21
+ * const obolClient = new Client(config);
22
+ * await obolClient.incentives.claimIncentives(address);
23
+ */
20
24
  export class Incentives {
21
- private readonly signer: Signer | JsonRpcSigner | undefined;
25
+ private readonly signer: SignerType | undefined;
22
26
  public readonly chainId: number;
23
27
  private readonly request: (
24
28
  endpoint: string,
25
29
  options?: RequestInit,
26
30
  ) => Promise<any>;
27
31
 
28
- public readonly provider:
29
- | Provider
30
- | JsonRpcProvider
31
- | JsonRpcApiProvider
32
- | undefined
33
- | null;
32
+ public readonly provider: ProviderType | undefined | null;
34
33
 
35
34
  constructor(
36
- signer: Signer | JsonRpcSigner | undefined,
35
+ signer: SignerType | undefined,
37
36
  chainId: number,
38
37
  request: (endpoint: string, options?: RequestInit) => Promise<any>,
39
- provider:
40
- | Provider
41
- | JsonRpcProvider
42
- | JsonRpcApiProvider
43
- | undefined
44
- | null,
38
+ provider: ProviderType | undefined | null,
45
39
  ) {
46
40
  this.signer = signer;
47
41
  this.chainId = chainId;
@@ -50,20 +44,25 @@ export class Incentives {
50
44
  }
51
45
 
52
46
  /**
53
- * Claims obol incentives from a Merkle Distributor contract using just an address.
54
- * The method automatically fetches incentives data and checks if already claimed.
47
+ * Claims Obol incentives from a Merkle Distributor contract using an address.
48
+ *
49
+ * This method automatically fetches incentive data and verifies whether the incentives have already been claimed.
50
+ * If `txHash` is `null`, it indicates that the incentives were already claimed.
51
+ *
52
+ * Note: This method is not yet enabled and will throw an error if called.
55
53
  *
56
54
  * @remarks
57
55
  * **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
58
56
  * and not pushed to version control.
59
57
  *
60
58
  * @param {string} address - The address to claim incentives for
61
- * @returns {Promise<{ txHash: string } | { alreadyClaimed: true }>} The transaction hash or already claimed status
59
+ * @returns {Promise<ClaimIncentivesResponse>} The transaction hash or already claimed status
62
60
  * @throws Will throw an error if the incentives data is not found or the claim fails
61
+ *
62
+ * An example of how to use claimIncentives:
63
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L281)
63
64
  */
64
- async claimIncentives(
65
- address: string,
66
- ): Promise<{ txHash: string } | { alreadyClaimed: true }> {
65
+ async claimIncentives(address: string): Promise<ClaimIncentivesResponse> {
67
66
  if (!this.signer) {
68
67
  throw new Error('Signer is required in claimIncentives');
69
68
  }
@@ -77,7 +76,7 @@ export class Incentives {
77
76
 
78
77
  const isContractDeployed = await isContractAvailable(
79
78
  incentivesData.contract_address,
80
- this.provider as Provider,
79
+ this.provider as ProviderType,
81
80
  );
82
81
 
83
82
  if (!isContractDeployed) {
@@ -92,7 +91,7 @@ export class Incentives {
92
91
  );
93
92
 
94
93
  if (claimed) {
95
- return { alreadyClaimed: true };
94
+ return { txHash: null };
96
95
  }
97
96
 
98
97
  const { txHash } = await claimIncentivesFromMerkleDistributor({
@@ -118,6 +117,9 @@ export class Incentives {
118
117
  * @param {ETH_ADDRESS} index - operator index in merkle tree
119
118
  * @returns {Promise<boolean>} true if incentives are already claime
120
119
  *
120
+ *
121
+ * An example of how to use isClaimed:
122
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L266)
121
123
  */
122
124
  async isClaimed(
123
125
  contractAddress: ETH_ADDRESS,
@@ -135,6 +137,9 @@ export class Incentives {
135
137
  * @param address - Operator address
136
138
  * @returns {Promise<IncentivesType>} The matched incentives from DB
137
139
  * @throws On not found if address not found.
140
+ *
141
+ * An example of how to use getIncentivesByAddress:
142
+ * [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L250)
138
143
  */
139
144
  async getIncentivesByAddress(address: string): Promise<IncentivesType> {
140
145
  const network = FORK_NAMES[this.chainId];
package/src/index.ts CHANGED
@@ -1,11 +1,4 @@
1
- import {
2
- ZeroAddress,
3
- type Provider,
4
- type Signer,
5
- type JsonRpcSigner,
6
- type JsonRpcProvider,
7
- type JsonRpcApiProvider,
8
- } from 'ethers';
1
+ import { ZeroAddress } from 'ethers';
9
2
  import { v4 as uuidv4 } from 'uuid';
10
3
  import { Base } from './base.js';
11
4
  import {
@@ -37,6 +30,8 @@ import {
37
30
  type ClusterValidator,
38
31
  type ETH_ADDRESS,
39
32
  type OWRTranches,
33
+ type ProviderType,
34
+ type SignerType,
40
35
  } from './types.js';
41
36
  import { clusterConfigOrDefinitionHash } from './verification/common.js';
42
37
  import { validatePayload } from './ajv.js';
@@ -59,19 +54,28 @@ export * from './types.js';
59
54
  export * from './services.js';
60
55
  export * from './verification/signature-validator.js';
61
56
  export * from './verification/common.js';
57
+ export { Incentives } from './incentives.js';
62
58
 
63
59
  /**
64
60
  * Obol sdk Client can be used for creating, managing and activating distributed validators.
65
61
  */
66
62
  export class Client extends Base {
67
- private readonly signer: Signer | JsonRpcSigner | undefined;
63
+ /**
64
+ * The signer used for signing transactions.
65
+ */
66
+ private readonly signer: SignerType | undefined;
67
+
68
+ /**
69
+ * The incentives module, responsible for managing Obol tokens distribution.
70
+ * @type {Incentives}
71
+ */
68
72
  public incentives: Incentives;
69
- public provider:
70
- | Provider
71
- | JsonRpcProvider
72
- | JsonRpcApiProvider
73
- | undefined
74
- | null;
73
+
74
+ /**
75
+ * The blockchain provider, used to interact with the network.
76
+ * It can be null, undefined, or a valid provider instance and defaults to the Signer provider if Signer is passed.
77
+ */
78
+ public provider: ProviderType | undefined | null;
75
79
 
76
80
  /**
77
81
  * @param config - Client configurations
@@ -85,8 +89,8 @@ export class Client extends Base {
85
89
  */
86
90
  constructor(
87
91
  config: { baseUrl?: string; chainId?: number },
88
- signer?: Signer | JsonRpcSigner,
89
- provider?: Provider | JsonRpcProvider,
92
+ signer?: SignerType,
93
+ provider?: ProviderType,
90
94
  ) {
91
95
  super(config);
92
96
  this.signer = signer;
@@ -201,19 +205,19 @@ export class Client extends Base {
201
205
 
202
206
  const checkSplitMainAddress = await isContractAvailable(
203
207
  CHAIN_CONFIGURATION[this.chainId].SPLITMAIN_ADDRESS.address,
204
- this.signer.provider as Provider,
208
+ this.signer.provider as ProviderType,
205
209
  CHAIN_CONFIGURATION[this.chainId].SPLITMAIN_ADDRESS.bytecode,
206
210
  );
207
211
 
208
212
  const checkMulticallAddress = await isContractAvailable(
209
213
  CHAIN_CONFIGURATION[this.chainId].MULTICALL_ADDRESS.address,
210
- this.signer.provider as Provider,
214
+ this.signer.provider as ProviderType,
211
215
  CHAIN_CONFIGURATION[this.chainId].MULTICALL_ADDRESS.bytecode,
212
216
  );
213
217
 
214
218
  const checkOWRFactoryAddress = await isContractAvailable(
215
219
  CHAIN_CONFIGURATION[this.chainId].OWR_FACTORY_ADDRESS.address,
216
- this.signer.provider as Provider,
220
+ this.signer.provider as ProviderType,
217
221
  CHAIN_CONFIGURATION[this.chainId].OWR_FACTORY_ADDRESS.bytecode,
218
222
  );
219
223
 
@@ -251,7 +255,7 @@ export class Client extends Base {
251
255
 
252
256
  const isSplitterDeployed = await isContractAvailable(
253
257
  predictedSplitterAddress,
254
- this.signer.provider as Provider,
258
+ this.signer.provider as ProviderType,
255
259
  );
256
260
 
257
261
  const { withdrawal_address, fee_recipient_address } =
@@ -316,7 +320,7 @@ export class Client extends Base {
316
320
 
317
321
  const checkSplitMainAddress = await isContractAvailable(
318
322
  CHAIN_CONFIGURATION[this.chainId].SPLITMAIN_ADDRESS.address,
319
- this.signer.provider as Provider,
323
+ this.signer.provider as ProviderType,
320
324
  CHAIN_CONFIGURATION[this.chainId].SPLITMAIN_ADDRESS.bytecode,
321
325
  );
322
326
 
@@ -349,7 +353,7 @@ export class Client extends Base {
349
353
 
350
354
  const isSplitterDeployed = await isContractAvailable(
351
355
  predictedSplitterAddress,
352
- this.signer.provider as Provider,
356
+ this.signer.provider as ProviderType,
353
357
  );
354
358
 
355
359
  if (!isSplitterDeployed) {
@@ -3,14 +3,9 @@ import {
3
3
  type ClusterValidator,
4
4
  type ETH_ADDRESS,
5
5
  type SplitRecipient,
6
+ type SignerType,
6
7
  } from './types';
7
- import {
8
- Contract,
9
- Interface,
10
- parseEther,
11
- ZeroAddress,
12
- type Signer,
13
- } from 'ethers';
8
+ import { Contract, Interface, parseEther, ZeroAddress } from 'ethers';
14
9
  import { OWRContract, OWRFactoryContract } from './abi/OWR';
15
10
  import { splitMainEthereumAbi } from './abi/SplitMain';
16
11
  import { MultiCallContract } from './abi/Multicall';
@@ -59,7 +54,7 @@ export const predictSplitterAddress = async ({
59
54
  distributorFee,
60
55
  controllerAddress,
61
56
  }: {
62
- signer: Signer;
57
+ signer: SignerType;
63
58
  accounts: ETH_ADDRESS[];
64
59
  percentAllocations: number[];
65
60
  chainId: number;
@@ -111,7 +106,7 @@ export const handleDeployOWRAndSplitter = async ({
111
106
  controllerAddress,
112
107
  recoveryAddress,
113
108
  }: {
114
- signer: Signer;
109
+ signer: SignerType;
115
110
  isSplitterDeployed: boolean;
116
111
  predictedSplitterAddress: ETH_ADDRESS;
117
112
  accounts: ETH_ADDRESS[];
@@ -174,7 +169,7 @@ const createOWRContract = async ({
174
169
  chainId,
175
170
  }: {
176
171
  owrArgs: OWRArgs;
177
- signer: Signer;
172
+ signer: SignerType;
178
173
  chainId: number;
179
174
  }): Promise<ETH_ADDRESS> => {
180
175
  try {
@@ -209,7 +204,7 @@ export const deploySplitterContract = async ({
209
204
  distributorFee,
210
205
  controllerAddress,
211
206
  }: {
212
- signer: Signer;
207
+ signer: SignerType;
213
208
  accounts: ETH_ADDRESS[];
214
209
  percentAllocations: number[];
215
210
  chainId: number;
@@ -247,7 +242,7 @@ export const deploySplitterAndOWRContracts = async ({
247
242
  }: {
248
243
  owrArgs: OWRArgs;
249
244
  splitterArgs: SplitArgs;
250
- signer: Signer;
245
+ signer: SignerType;
251
246
  chainId: number;
252
247
  }): Promise<{ owrAddress: ETH_ADDRESS; splitterAddress: ETH_ADDRESS }> => {
253
248
  const executeCalls: Call[] = [];
@@ -304,7 +299,7 @@ export const getOWRTranches = async ({
304
299
  signer,
305
300
  }: {
306
301
  owrAddress: ETH_ADDRESS;
307
- signer: Signer;
302
+ signer: SignerType;
308
303
  }): Promise<OWRTranches> => {
309
304
  const owrContract = new Contract(owrAddress, OWRContract.abi, signer);
310
305
  const res = await owrContract.getTranches();
@@ -318,7 +313,7 @@ export const getOWRTranches = async ({
318
313
 
319
314
  export const multicall = async (
320
315
  calls: Call[],
321
- signer: Signer,
316
+ signer: SignerType,
322
317
  multicallAddress: string,
323
318
  ): Promise<any> => {
324
319
  const multiCallContractInstance = new Contract(
package/src/types.ts CHANGED
@@ -1,3 +1,12 @@
1
+ import {
2
+ type ethers,
3
+ type JsonRpcApiProvider,
4
+ type JsonRpcProvider,
5
+ type JsonRpcSigner,
6
+ type Provider,
7
+ type Signer,
8
+ } from 'ethers';
9
+
1
10
  /**
2
11
  * Permitted ChainID's
3
12
  */
@@ -21,28 +30,14 @@ export enum FORK_MAPPING {
21
30
  '0x10000910' = 560048,
22
31
  }
23
32
 
24
- /**
25
- * Permitted Chain Names
26
- */
27
33
  export const FORK_NAMES: Record<number, string> = {
28
- /** Mainnet. */
29
34
  [FORK_MAPPING['0x00000000']]: 'mainnet',
30
-
31
- /** Goerli/Prater. */
32
35
  [FORK_MAPPING['0x00001020']]: 'goerli',
33
-
34
- /** Gnosis Chain. */
35
36
  [FORK_MAPPING['0x00000064']]: 'gnosis',
36
-
37
- /** Holesky. */
38
37
  [FORK_MAPPING['0x01017000']]: 'holesky',
39
-
40
- /** Sepolia. */
41
38
  [FORK_MAPPING['0x90000069']]: 'sepolia',
42
-
43
- /** Hoodi. */
44
39
  [FORK_MAPPING['0x10000910']]: 'hoodi',
45
- };
40
+ } as const;
46
41
 
47
42
  /**
48
43
  * Node operator data
@@ -323,3 +318,22 @@ export type Incentives = {
323
318
  * String expected to be Ethereum Address
324
319
  */
325
320
  export type ETH_ADDRESS = string;
321
+
322
+ /**
323
+ * Provider Types
324
+ */
325
+ export type ProviderType =
326
+ | Provider
327
+ | JsonRpcProvider
328
+ | JsonRpcApiProvider
329
+ | ethers.BrowserProvider;
330
+
331
+ /**
332
+ * Signer Types
333
+ */
334
+ export type SignerType = Signer | JsonRpcSigner;
335
+
336
+ /**
337
+ * claimIncentives Response
338
+ */
339
+ export type ClaimIncentivesResponse = { txHash: string | null };
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ethers, type Provider } from 'ethers';
1
+ import { ethers } from 'ethers';
2
2
  import { DefinitionFlow, PROVIDER_MAP } from './constants';
3
- import { FORK_NAMES, type ClusterDefinition } from './types';
3
+ import { FORK_NAMES, type ProviderType, type ClusterDefinition } from './types';
4
4
 
5
5
  export const hexWithout0x = (hex: string): string => {
6
6
  return hex.slice(2, hex.length);
@@ -58,14 +58,14 @@ export const definitionFlow = (
58
58
 
59
59
  export const findDeployedBytecode = async (
60
60
  contractAddress: string,
61
- provider: Provider,
61
+ provider: ProviderType,
62
62
  ): Promise<string> => {
63
63
  return await provider?.getCode(contractAddress);
64
64
  };
65
65
 
66
66
  export const isContractAvailable = async (
67
67
  contractAddress: string,
68
- provider: Provider,
68
+ provider: ProviderType,
69
69
  bytecode?: string,
70
70
  ): Promise<boolean> => {
71
71
  const code = await findDeployedBytecode(contractAddress, provider);
@@ -76,7 +76,7 @@ export const isContractAvailable = async (
76
76
  return !!code && code !== '0x' && code !== '0x0';
77
77
  };
78
78
 
79
- export const getProvider = (chainId: number): ethers.Provider => {
79
+ export const getProvider = (chainId: number): ethers.JsonRpcProvider => {
80
80
  const rpcUrl = PROVIDER_MAP[chainId];
81
81
  if (!rpcUrl || rpcUrl === 'undefined') {
82
82
  throw new Error(`No provider configured for ${FORK_NAMES[chainId]}`);