diff --git a/blockchain/MNDContract.ts b/blockchain/MNDContract.ts index 9570c06..d8c5d5c 100644 --- a/blockchain/MNDContract.ts +++ b/blockchain/MNDContract.ts @@ -788,14 +788,19 @@ export const MNDContractAbi = [ type: 'address', }, { - internalType: 'uint256[]', - name: 'epochs', - type: 'uint256[]', + internalType: 'uint256', + name: 'fromEpoch', + type: 'uint256', }, { - internalType: 'uint8[]', - name: 'availabilies', - type: 'uint8[]', + internalType: 'uint256', + name: 'toEpoch', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'packedAvailabilities', + type: 'bytes', }, ], internalType: 'struct ComputeRewardsParams[]', @@ -851,14 +856,19 @@ export const MNDContractAbi = [ type: 'address', }, { - internalType: 'uint256[]', - name: 'epochs', - type: 'uint256[]', + internalType: 'uint256', + name: 'fromEpoch', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'toEpoch', + type: 'uint256', }, { - internalType: 'uint8[]', - name: 'availabilies', - type: 'uint8[]', + internalType: 'bytes', + name: 'packedAvailabilities', + type: 'bytes', }, ], internalType: 'struct ComputeRewardsParams[]', @@ -1738,14 +1748,19 @@ export const MNDContractAbi = [ type: 'address', }, { - internalType: 'uint256[]', - name: 'epochs', - type: 'uint256[]', + internalType: 'uint256', + name: 'fromEpoch', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'toEpoch', + type: 'uint256', }, { - internalType: 'uint8[]', - name: 'availabilies', - type: 'uint8[]', + internalType: 'bytes', + name: 'packedAvailabilities', + type: 'bytes', }, ], internalType: 'struct ComputeRewardsParams', diff --git a/lib/api/blockchain.ts b/lib/api/blockchain.ts index cf096af..d101ab5 100644 --- a/lib/api/blockchain.ts +++ b/lib/api/blockchain.ts @@ -607,13 +607,24 @@ const getMndOrGndLicenseRewardsBreakdown = async ( epochs_vals = epochs_vals.slice(start); } - if (epochsToClaim !== epochs.length || epochsToClaim !== epochs_vals.length) { + const epochsAreContiguous = epochs.every((epoch, index) => epoch === firstEpochToClaim + index); + + if ( + epochsToClaim !== epochs.length || + epochsToClaim !== epochs_vals.length || + !epochsAreContiguous || + epochs[0] !== firstEpochToClaim || + epochs[epochs.length - 1] !== currentEpoch - 1 + ) { return { claimableAmount: undefined, }; } const publicClient = await getPublicClient(); + const packedAvailabilities = `0x${epochs_vals + .map((availability) => availability.toString(16).padStart(2, '0')) + .join('')}` as `0x${string}`; let result: ReadContractReturnType | undefined; @@ -627,8 +638,9 @@ const getMndOrGndLicenseRewardsBreakdown = async ( { licenseId, nodeAddress: license.nodeAddress, - epochs: epochs.map((epoch) => BigInt(epoch)), - availabilies: epochs_vals, + fromEpoch: BigInt(firstEpochToClaim), + toEpoch: BigInt(currentEpoch - 1), + packedAvailabilities, }, ], ], diff --git a/typedefs/blockchain.ts b/typedefs/blockchain.ts index d871157..56af800 100644 --- a/typedefs/blockchain.ts +++ b/typedefs/blockchain.ts @@ -52,8 +52,9 @@ type CachedLicense = { type ComputeParam = { licenseId: bigint; nodeAddress: `0x${string}`; - epochs: bigint[]; - availabilies: number[]; + fromEpoch: bigint; + toEpoch: bigint; + packedAvailabilities: `0x${string}`; }; type OraclesAvailabilityResult = {