Skip to content

Commit

Permalink
fix(apis): remove epoch from distributions and observations
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 15, 2024
1 parent 908971c commit 7b2d279
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ const observations = await arIO.getObservations();

### `getDistributions({ evaluationOptions })`

Returns the current rewards distribution information.
Returns the current rewards distribution information. The resulting object is pruned, to get older distributions use the `evaluationOptions` to `evalTo` a previous state.

```typescript
const arIO = new ArIO();
Expand Down
6 changes: 1 addition & 5 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,13 @@ export interface ArIOContract {
evaluationOptions,
}: EvaluationParameters): Promise<EpochDistributionData>;
getObservations({
epochStartHeight,
evaluationOptions,
}: EvaluationParameters<{
epochStartHeight?: number;
}>): Promise<Observations>;
getDistributions({
epochStartHeight,
evaluationOptions,
}: EvaluationParameters<{
epochStartHeight?: number;
}>): Promise<EpochDistributionData>;
}: EvaluationParameters): Promise<EpochDistributionData>;
}

/* eslint-disable @typescript-eslint/no-explicit-any */
Expand Down
24 changes: 5 additions & 19 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,35 +185,21 @@ export class ArIO implements ArIOContract {
});
}
async getObservations({
epochStartHeight,
evaluationOptions,
}: EvaluationParameters<{
epochStartHeight?: number;
}> = {}): Promise<Observations> {
const { observations } = await this.contract.getContractState({
evaluationOptions,
});
return epochStartHeight !== undefined
? { [epochStartHeight]: observations[epochStartHeight] }
: observations;
return observations;
}
async getDistributions({
epochStartHeight,
evaluationOptions,
}: EvaluationParameters<{
epochStartHeight?: number;
}> = {}): Promise<EpochDistributionData> {
const distributions =
epochStartHeight !== undefined
? await this.getEpoch({
...evaluationOptions,
blockHeight: epochStartHeight,
})
: await this.contract
.getContractState({
evaluationOptions,
})
.then((state) => state.distributions);
}: EvaluationParameters = {}): Promise<EpochDistributionData> {
const { distributions } = await this.contract.getContractState({
evaluationOptions,
});
return distributions;
}
}

0 comments on commit 7b2d279

Please sign in to comment.