@obolnetwork/obol-sdk 2.11.3 → 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.
- package/dist/cjs/src/index.js +17457 -382
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/esm/src/index.js +17424 -361
- package/dist/esm/src/index.js.map +1 -0
- package/dist/types/src/abi/OVM.d.ts +103 -0
- package/dist/types/src/bytecodes.d.ts +3 -2
- package/dist/types/src/constants.d.ts +1 -2
- package/dist/types/src/eoa/eoaHelpers.d.ts +1 -1
- package/dist/types/src/exits/verificationHelpers.d.ts +0 -2
- package/dist/types/src/incentives/incentiveHelpers.d.ts +1 -1
- package/dist/types/src/splits/splitHelpers.d.ts +3 -3
- package/dist/types/src/utils.d.ts +2 -2
- package/dist/types/src/verification/common.d.ts +0 -2
- package/dist/types/src/verification/signature-validator.d.ts +4 -4
- package/dist/types/src/verification/v1.10.0.d.ts +1 -1
- package/dist/types/src/verification/v1.6.0.d.ts +1 -1
- package/dist/types/src/verification/v1.7.0.d.ts +1 -1
- package/dist/types/src/verification/v1.8.0.d.ts +1 -1
- package/dist/types/test/client/methods.spec.d.ts +17 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/tsup.config.d.ts +2 -0
- package/package.json +79 -54
- package/dist/cjs/package.json +0 -139
- package/dist/cjs/src/abi/BatchDeposit.js +0 -120
- package/dist/cjs/src/abi/MerkleDistributorWithDeadline.js +0 -73
- package/dist/cjs/src/abi/Multicall3.js +0 -253
- package/dist/cjs/src/abi/OVMFactory.js +0 -620
- package/dist/cjs/src/abi/OWR.js +0 -304
- package/dist/cjs/src/abi/SplitMain.js +0 -929
- package/dist/cjs/src/abi/splitV2FactoryAbi.js +0 -420
- package/dist/cjs/src/ajv.js +0 -136
- package/dist/cjs/src/base.js +0 -42
- package/dist/cjs/src/bytecodes.js +0 -18
- package/dist/cjs/src/constants.js +0 -268
- package/dist/cjs/src/eoa/eoa.js +0 -132
- package/dist/cjs/src/eoa/eoaHelpers.js +0 -82
- package/dist/cjs/src/errors.js +0 -11
- package/dist/cjs/src/exits/ethUtils.js +0 -57
- package/dist/cjs/src/exits/exit.js +0 -502
- package/dist/cjs/src/exits/verificationHelpers.js +0 -86
- package/dist/cjs/src/incentives/incentiveHelpers.js +0 -39
- package/dist/cjs/src/incentives/incentives.js +0 -119
- package/dist/cjs/src/schema.js +0 -352
- package/dist/cjs/src/services.js +0 -33
- package/dist/cjs/src/splits/splitHelpers.js +0 -571
- package/dist/cjs/src/splits/splits.js +0 -366
- package/dist/cjs/src/types.js +0 -29
- package/dist/cjs/src/utils.js +0 -77
- package/dist/cjs/src/verification/common.js +0 -355
- package/dist/cjs/src/verification/signature-validator.js +0 -73
- package/dist/cjs/src/verification/sszTypes.js +0 -69
- package/dist/cjs/src/verification/termsAndConditions.js +0 -40
- package/dist/cjs/src/verification/v1.10.0.js +0 -146
- package/dist/cjs/src/verification/v1.6.0.js +0 -149
- package/dist/cjs/src/verification/v1.7.0.js +0 -173
- package/dist/cjs/src/verification/v1.8.0.js +0 -196
- package/dist/cjs/test/client/ajv.spec.js +0 -320
- package/dist/cjs/test/client/methods.spec.js +0 -418
- package/dist/cjs/test/eoa/eoa.spec.js +0 -176
- package/dist/cjs/test/exit/ethUtils.spec.js +0 -83
- package/dist/cjs/test/exit/exit.spec.js +0 -399
- package/dist/cjs/test/exit/verificationHelpers.spec.js +0 -68
- package/dist/cjs/test/fixtures.js +0 -896
- package/dist/cjs/test/incentives/incentives.spec.js +0 -202
- package/dist/cjs/test/splits/splits.spec.js +0 -402
- package/dist/esm/package.json +0 -139
- package/dist/esm/src/abi/BatchDeposit.js +0 -117
- package/dist/esm/src/abi/MerkleDistributorWithDeadline.js +0 -70
- package/dist/esm/src/abi/Multicall3.js +0 -250
- package/dist/esm/src/abi/OVMFactory.js +0 -617
- package/dist/esm/src/abi/OWR.js +0 -301
- package/dist/esm/src/abi/SplitMain.js +0 -926
- package/dist/esm/src/abi/splitV2FactoryAbi.js +0 -417
- package/dist/esm/src/ajv.js +0 -129
- package/dist/esm/src/base.js +0 -38
- package/dist/esm/src/bytecodes.js +0 -15
- package/dist/esm/src/constants.js +0 -234
- package/dist/esm/src/eoa/eoa.js +0 -128
- package/dist/esm/src/eoa/eoaHelpers.js +0 -77
- package/dist/esm/src/errors.js +0 -7
- package/dist/esm/src/exits/ethUtils.js +0 -52
- package/dist/esm/src/exits/exit.js +0 -475
- package/dist/esm/src/exits/verificationHelpers.js +0 -81
- package/dist/esm/src/incentives/incentiveHelpers.js +0 -34
- package/dist/esm/src/incentives/incentives.js +0 -115
- package/dist/esm/src/schema.js +0 -349
- package/dist/esm/src/services.js +0 -29
- package/dist/esm/src/splits/splitHelpers.js +0 -554
- package/dist/esm/src/splits/splits.js +0 -362
- package/dist/esm/src/types.js +0 -26
- package/dist/esm/src/utils.js +0 -68
- package/dist/esm/src/verification/common.js +0 -319
- package/dist/esm/src/verification/signature-validator.js +0 -64
- package/dist/esm/src/verification/sszTypes.js +0 -64
- package/dist/esm/src/verification/termsAndConditions.js +0 -33
- package/dist/esm/src/verification/v1.10.0.js +0 -140
- package/dist/esm/src/verification/v1.6.0.js +0 -142
- package/dist/esm/src/verification/v1.7.0.js +0 -166
- package/dist/esm/src/verification/v1.8.0.js +0 -189
- package/dist/esm/test/client/ajv.spec.js +0 -318
- package/dist/esm/test/client/methods.spec.js +0 -393
- package/dist/esm/test/eoa/eoa.spec.js +0 -174
- package/dist/esm/test/exit/ethUtils.spec.js +0 -81
- package/dist/esm/test/exit/exit.spec.js +0 -374
- package/dist/esm/test/exit/verificationHelpers.spec.js +0 -66
- package/dist/esm/test/fixtures.js +0 -893
- package/dist/esm/test/incentives/incentives.spec.js +0 -177
- package/dist/esm/test/splits/splits.spec.js +0 -400
- package/dist/types/src/abi/OVMFactory.d.ts +0 -662
- package/src/abi/BatchDeposit.ts +0 -117
- package/src/abi/MerkleDistributorWithDeadline.ts +0 -70
- package/src/abi/Multicall3.ts +0 -250
- package/src/abi/OVMFactory.ts +0 -617
- package/src/abi/OWR.ts +0 -302
- package/src/abi/SplitMain.ts +0 -927
- package/src/abi/splitV2FactoryAbi.ts +0 -417
- package/src/ajv.ts +0 -191
- package/src/base.ts +0 -54
- package/src/bytecodes.ts +0 -31
- package/src/constants.ts +0 -304
- package/src/eoa/eoa.ts +0 -153
- package/src/eoa/eoaHelpers.ts +0 -112
- package/src/errors.ts +0 -8
- package/src/exits/ethUtils.ts +0 -49
- package/src/exits/exit.ts +0 -661
- package/src/exits/verificationHelpers.ts +0 -110
- package/src/incentives/incentiveHelpers.ts +0 -55
- package/src/incentives/incentives.ts +0 -153
- package/src/index.ts +0 -614
- package/src/schema.ts +0 -376
- package/src/services.ts +0 -24
- package/src/splits/splitHelpers.ts +0 -1032
- package/src/splits/splits.ts +0 -504
- package/src/types.ts +0 -687
- package/src/utils.ts +0 -88
- package/src/verification/common.ts +0 -532
- package/src/verification/signature-validator.ts +0 -103
- package/src/verification/sszTypes.ts +0 -88
- package/src/verification/termsAndConditions.ts +0 -32
- package/src/verification/v1.10.0.ts +0 -245
- package/src/verification/v1.6.0.ts +0 -256
- package/src/verification/v1.7.0.ts +0 -309
- package/src/verification/v1.8.0.ts +0 -340
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { ContainerType, ByteVectorType, fromHexString } from '@chainsafe/ssz';
|
|
2
|
-
|
|
3
|
-
// From obol-api/src/verification/common.ts
|
|
4
|
-
export const GENESIS_VALIDATOR_ROOT_HEX_STRING =
|
|
5
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000'; // Added 0x prefix
|
|
6
|
-
|
|
7
|
-
const ForkDataType = new ContainerType({
|
|
8
|
-
currentVersion: new ByteVectorType(4),
|
|
9
|
-
genesisValidatorsRoot: new ByteVectorType(32),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const SigningRootType = new ContainerType({
|
|
13
|
-
objectRoot: new ByteVectorType(32),
|
|
14
|
-
domain: new ByteVectorType(32),
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#compute_fork_data_root
|
|
19
|
-
* @param currentVersion - Uint8Array of the current fork version.
|
|
20
|
-
* @param genesisValidatorsRoot - Uint8Array of the genesis validators root.
|
|
21
|
-
* @returns Uint8Array - The 32-byte fork data root.
|
|
22
|
-
*/
|
|
23
|
-
function computeForkDataRoot(
|
|
24
|
-
currentVersion: Uint8Array,
|
|
25
|
-
genesisValidatorsRoot: Uint8Array,
|
|
26
|
-
): Uint8Array {
|
|
27
|
-
const forkDataVal = ForkDataType.defaultValue();
|
|
28
|
-
forkDataVal.currentVersion = currentVersion;
|
|
29
|
-
forkDataVal.genesisValidatorsRoot = genesisValidatorsRoot;
|
|
30
|
-
return Buffer.from(ForkDataType.hashTreeRoot(forkDataVal).buffer);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Computes the domain for a given domain type, fork version, and genesis state.
|
|
35
|
-
* https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#compute_domain
|
|
36
|
-
* @param domainType - Uint8Array representing the domain type (e.g., DOMAIN_VOLUNTARY_EXIT).
|
|
37
|
-
* @param forkVersionString - Hex string of the fork version (e.g., Capella fork version).
|
|
38
|
-
* @param genesisValidatorsRootOverride - Optional Uint8Array to override the default genesis validators root.
|
|
39
|
-
* @returns Uint8Array - The 32-byte domain.
|
|
40
|
-
*/
|
|
41
|
-
export function computeDomain(
|
|
42
|
-
domainType: Uint8Array, // Should be 4 bytes
|
|
43
|
-
forkVersionString: string, // Hex string, e.g., '0x03000000'
|
|
44
|
-
genesisValidatorsRootOverride?: Uint8Array, // 32 bytes
|
|
45
|
-
): Uint8Array {
|
|
46
|
-
const forkVersionBytes = fromHexString(
|
|
47
|
-
forkVersionString.substring(2, forkVersionString.length),
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
if (forkVersionBytes.length !== 4) {
|
|
51
|
-
throw new Error('Fork version must be 4 bytes');
|
|
52
|
-
}
|
|
53
|
-
if (domainType.length !== 4) {
|
|
54
|
-
throw new Error('Domain type must be 4 bytes');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const actualGenesisValidatorsRoot =
|
|
58
|
-
genesisValidatorsRootOverride ??
|
|
59
|
-
fromHexString(GENESIS_VALIDATOR_ROOT_HEX_STRING.substring(2));
|
|
60
|
-
|
|
61
|
-
if (actualGenesisValidatorsRoot.length !== 32) {
|
|
62
|
-
throw new Error('genesisValidatorsRoot must be 32 bytes');
|
|
63
|
-
}
|
|
64
|
-
const forkDataRoot = computeForkDataRoot(
|
|
65
|
-
forkVersionBytes,
|
|
66
|
-
actualGenesisValidatorsRoot,
|
|
67
|
-
);
|
|
68
|
-
const domain = new Uint8Array(32);
|
|
69
|
-
domain.set(domainType);
|
|
70
|
-
domain.set(forkDataRoot.subarray(0, 28), 4); // Set the remaining 28 bytes from forkDataRoot
|
|
71
|
-
return domain;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Computes the signing root for an SSZ object and a domain.
|
|
76
|
-
* https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#compute_signing_root
|
|
77
|
-
* @param sszObjectRoot - Uint8Array of the hash tree root of the SSZ object.
|
|
78
|
-
* @param domain - Uint8Array of the domain.
|
|
79
|
-
* @returns Uint8Array - The 32-byte signing root.
|
|
80
|
-
*/
|
|
81
|
-
function computeSigningRoot(
|
|
82
|
-
sszObjectRoot: Uint8Array, // Should be 32 bytes
|
|
83
|
-
domain: Uint8Array, // Should be 32 bytes
|
|
84
|
-
): Uint8Array {
|
|
85
|
-
if (sszObjectRoot.length !== 32) {
|
|
86
|
-
throw new Error('SSZ object root must be 32 bytes');
|
|
87
|
-
}
|
|
88
|
-
if (domain.length !== 32) {
|
|
89
|
-
throw new Error('Domain must be 32 bytes');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const val = SigningRootType.defaultValue();
|
|
93
|
-
val.objectRoot = sszObjectRoot;
|
|
94
|
-
val.domain = domain;
|
|
95
|
-
return Buffer.from(SigningRootType.hashTreeRoot(val).buffer);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Convenience wrapper for computeSigningRoot.
|
|
100
|
-
* @param domain - Uint8Array of the domain.
|
|
101
|
-
* @param messageBuffer - Buffer of the message (SSZ object root).
|
|
102
|
-
* @returns Uint8Array - The signing root.
|
|
103
|
-
*/
|
|
104
|
-
export function signingRoot(
|
|
105
|
-
domain: Uint8Array,
|
|
106
|
-
messageBuffer: Buffer, // Assumed to be the 32-byte sszObjectRoot
|
|
107
|
-
): Uint8Array {
|
|
108
|
-
const sszObjectRootU8 = Uint8Array.from(messageBuffer);
|
|
109
|
-
return computeSigningRoot(sszObjectRootU8, domain);
|
|
110
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { type ProviderType, type SignerType, type ETH_ADDRESS } from '../types';
|
|
2
|
-
import { Contract } from 'ethers';
|
|
3
|
-
import { MerkleDistributorABI } from '../abi/MerkleDistributorWithDeadline';
|
|
4
|
-
|
|
5
|
-
export const claimIncentivesFromMerkleDistributor = async (incentivesData: {
|
|
6
|
-
signer: SignerType;
|
|
7
|
-
contractAddress: ETH_ADDRESS;
|
|
8
|
-
index: number;
|
|
9
|
-
operatorAddress: ETH_ADDRESS;
|
|
10
|
-
amount: string;
|
|
11
|
-
merkleProof: string[];
|
|
12
|
-
}): Promise<{ txHash: string }> => {
|
|
13
|
-
try {
|
|
14
|
-
const contract = new Contract(
|
|
15
|
-
incentivesData.contractAddress,
|
|
16
|
-
MerkleDistributorABI.abi,
|
|
17
|
-
incentivesData.signer,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const tx = await contract.claim(
|
|
21
|
-
BigInt(incentivesData.index),
|
|
22
|
-
incentivesData.operatorAddress,
|
|
23
|
-
BigInt(incentivesData.amount),
|
|
24
|
-
incentivesData.merkleProof,
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const receipt = await tx.wait();
|
|
28
|
-
|
|
29
|
-
return { txHash: receipt.hash };
|
|
30
|
-
} catch (error: any) {
|
|
31
|
-
console.log('Error claiming incentives:', error);
|
|
32
|
-
throw new Error(`Failed to claim incentives: ${error.message}`);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const isClaimedFromMerkleDistributor = async (
|
|
37
|
-
contractAddress: ETH_ADDRESS,
|
|
38
|
-
index: number,
|
|
39
|
-
provider: ProviderType | undefined | null,
|
|
40
|
-
): Promise<boolean> => {
|
|
41
|
-
try {
|
|
42
|
-
const contract = new Contract(
|
|
43
|
-
contractAddress,
|
|
44
|
-
MerkleDistributorABI.abi,
|
|
45
|
-
provider,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const claimed = await contract.isClaimed(BigInt(index));
|
|
49
|
-
|
|
50
|
-
return claimed;
|
|
51
|
-
} catch (error: any) {
|
|
52
|
-
console.log('Error checking claim status:', error);
|
|
53
|
-
throw new Error(`Failed to check claim status: ${error.message}`);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { isContractAvailable } from '../utils';
|
|
2
|
-
import {
|
|
3
|
-
type ClaimableIncentives,
|
|
4
|
-
type ETH_ADDRESS,
|
|
5
|
-
FORK_NAMES,
|
|
6
|
-
type ProviderType,
|
|
7
|
-
type SignerType,
|
|
8
|
-
type ClaimIncentivesResponse,
|
|
9
|
-
} from '../types';
|
|
10
|
-
import {
|
|
11
|
-
claimIncentivesFromMerkleDistributor,
|
|
12
|
-
isClaimedFromMerkleDistributor,
|
|
13
|
-
} from './incentiveHelpers';
|
|
14
|
-
import { DEFAULT_BASE_VERSION } from '../constants';
|
|
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
|
-
*/
|
|
24
|
-
export class Incentives {
|
|
25
|
-
private readonly signer: SignerType | undefined;
|
|
26
|
-
public readonly chainId: number;
|
|
27
|
-
private readonly request: (
|
|
28
|
-
endpoint: string,
|
|
29
|
-
options?: RequestInit,
|
|
30
|
-
) => Promise<any>;
|
|
31
|
-
|
|
32
|
-
public readonly provider: ProviderType | undefined | null;
|
|
33
|
-
|
|
34
|
-
constructor(
|
|
35
|
-
signer: SignerType | undefined,
|
|
36
|
-
chainId: number,
|
|
37
|
-
request: (endpoint: string, options?: RequestInit) => Promise<any>,
|
|
38
|
-
provider: ProviderType | undefined | null,
|
|
39
|
-
) {
|
|
40
|
-
this.signer = signer;
|
|
41
|
-
this.chainId = chainId;
|
|
42
|
-
this.request = request;
|
|
43
|
-
this.provider = provider;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
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.
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
56
|
-
* and not pushed to version control.
|
|
57
|
-
*
|
|
58
|
-
* @param {string} address - The address to claim incentives for
|
|
59
|
-
* @returns {Promise<ClaimIncentivesResponse>} The transaction hash or already claimed status
|
|
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)
|
|
64
|
-
*/
|
|
65
|
-
async claimIncentives(address: string): Promise<ClaimIncentivesResponse> {
|
|
66
|
-
if (!this.signer) {
|
|
67
|
-
throw new Error('Signer is required in claimIncentives');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const incentivesData = await this.getIncentivesByAddress(address);
|
|
72
|
-
|
|
73
|
-
if (!incentivesData?.contract_address) {
|
|
74
|
-
throw new Error(`No incentives found for address ${address}`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const isContractDeployed = await isContractAvailable(
|
|
78
|
-
incentivesData.contract_address,
|
|
79
|
-
this.provider as ProviderType,
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
if (!isContractDeployed) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
`Merkle Distributor contract is not available at address ${incentivesData.contract_address}`,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const claimed = await this.isClaimed(
|
|
89
|
-
incentivesData.contract_address,
|
|
90
|
-
incentivesData.index,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (claimed) {
|
|
94
|
-
return { txHash: null };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const { txHash } = await claimIncentivesFromMerkleDistributor({
|
|
98
|
-
signer: this.signer,
|
|
99
|
-
contractAddress: incentivesData.contract_address,
|
|
100
|
-
index: incentivesData.index,
|
|
101
|
-
operatorAddress: incentivesData.operator_address,
|
|
102
|
-
amount: incentivesData.amount,
|
|
103
|
-
merkleProof: incentivesData.merkle_proof,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
return { txHash };
|
|
107
|
-
} catch (error: any) {
|
|
108
|
-
console.log('Error claiming incentives:', error);
|
|
109
|
-
throw new Error(`Failed to claim incentives: ${error.message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Read isClaimed.
|
|
115
|
-
*
|
|
116
|
-
* @param {ETH_ADDRESS} contractAddress - Address of the Merkle Distributor Contract
|
|
117
|
-
* @param {ETH_ADDRESS} index - operator index in merkle tree
|
|
118
|
-
* @returns {Promise<boolean>} true if incentives are already claime
|
|
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)
|
|
123
|
-
*/
|
|
124
|
-
async isClaimed(
|
|
125
|
-
contractAddress: ETH_ADDRESS,
|
|
126
|
-
index: number,
|
|
127
|
-
): Promise<boolean> {
|
|
128
|
-
return await isClaimedFromMerkleDistributor(
|
|
129
|
-
contractAddress,
|
|
130
|
-
index,
|
|
131
|
-
this.provider,
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @param address - Operator address
|
|
137
|
-
* @returns {Promise<IncentivesType>} The matched incentives from DB
|
|
138
|
-
* @throws On not found if address not found.
|
|
139
|
-
*
|
|
140
|
-
* An example of how to use getIncentivesByAddress:
|
|
141
|
-
* [obolClient](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L250)
|
|
142
|
-
*/
|
|
143
|
-
async getIncentivesByAddress(address: string): Promise<ClaimableIncentives> {
|
|
144
|
-
const network = FORK_NAMES[this.chainId];
|
|
145
|
-
const incentives: ClaimableIncentives = await this.request(
|
|
146
|
-
`/${DEFAULT_BASE_VERSION}/address/incentives/${network}/${address}`,
|
|
147
|
-
{
|
|
148
|
-
method: 'GET',
|
|
149
|
-
},
|
|
150
|
-
);
|
|
151
|
-
return incentives;
|
|
152
|
-
}
|
|
153
|
-
}
|