Skip to content

Commit

Permalink
feat(ario contract): add distributions and observation apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 12, 2024
1 parent 3434ec5 commit 21e38d1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ArIOState, ArNSNameData, Gateway } from './contract-state.js';
import {
ArIOState,
ArNSNameData,
EpochDistributionData,
Gateway,
Observations,
} from './contract-state.js';

export type BlockHeight = number;
export type SortKey = string;
Expand Down Expand Up @@ -73,6 +79,12 @@ export interface ArIOContract {
}: EvaluationParameters): Promise<
Record<string, ArNSNameData> | Record<string, never>
>;
getObservations({
evaluationOptions,
}: EvaluationParameters): Promise<Observations>;
getDistributions({
evaluationOptions,
}: EvaluationParameters): Promise<EpochDistributionData>;
}

/* eslint-disable @typescript-eslint/no-explicit-any */
Expand Down
23 changes: 23 additions & 0 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import {
ArIOContract,
ArIOState,
ArNSNameData,
EpochDistributionData,
EvaluationOptions,
EvaluationParameters,
Gateway,
Observations,
SmartWeaveContract,
} from '../types.js';
import { RemoteContract } from './contracts/remote-contract.js';
Expand Down Expand Up @@ -149,4 +152,24 @@ export class ArIO implements ArIOContract {
evaluationOptions,
});
}
async getObservations({
evaluationOptions,
}: {
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
}): Promise<Observations> {
const { observations } = await this.contract.getContractState({
evaluationOptions,
});
return observations;
}
async getDistributions({
evaluationOptions,
}: {
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
}): Promise<EpochDistributionData> {
const { distributions } = await this.contract.getContractState({
evaluationOptions,
});
return distributions;
}
}

0 comments on commit 21e38d1

Please sign in to comment.