Skip to content

Commit

Permalink
Merge branch 'alpha' into PE-6952-arns-resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler authored Oct 15, 2024
2 parents 1380f04 + 7eaa504 commit 789c027
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 17 deletions.
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ const demandFactor = await io.getDemandFactor();

#### `getObservations({ epochIndex })`

Returns the epoch-indexed observation list.
Returns the epoch-indexed observation list. If no epoch index is provided, the current epoch is used.

```typescript
const io = IO.init();
Expand Down Expand Up @@ -625,23 +625,34 @@ const observations = await io.getObservations();

#### `getDistributions({ epochIndex })`

Returns the current rewards distribution information.
Returns the current rewards distribution information. If no epoch index is provided, the current epoch is used.

```typescript
const io = IO.init();
const distributions = await io.getDistributions();
const distributions = await io.getDistributions({ epochIndex: 0 });
```

<details>
<summary>Output</summary>

```json
{
"totalEligibleGateways": 1,
"totalEligibleRewards": 100000000,
"totalEligibleObserverReward": 100000000,
"totalEligibleGatewayReward": 100000000,
"totalDistributedRewards": 100000000,
"distributedTimestamp": 1720720621424,
"rewards": {
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
"eligible": {
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": {
"operatorReward": 100000000,
"delegateRewards": {}
}
},
"distributed": {
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
}
}
}
```
Expand All @@ -650,7 +661,7 @@ const distributions = await io.getDistributions();

#### `getEpoch({ epochIndex })`

Returns the epoch data for the specified block height.
Returns the epoch data for the specified block height. If no epoch index is provided, the current epoch is used.

```typescript
const io = IO.init();
Expand Down Expand Up @@ -693,11 +704,22 @@ const epoch = await io.getEpoch({ epochIndex: 0 });
}
],
"distributions": {
"distributedTimestamp": 1752256702026,
"totalEligibleGateways": 1,
"totalEligibleRewards": 100000000,
"totoalDistributedRewards": 100000000,
"totalEligibleObserverReward": 100000000,
"totalEligibleGatewayReward": 100000000,
"totalDistributedRewards": 100000000,
"distributedTimestamp": 1720720621424,
"rewards": {
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
"eligible": {
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": {
"operatorReward": 100000000,
"delegateRewards": {}
}
},
"distributed": {
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export type AoEpochDistributionRewards = {

export type AoEpochDistributionData = {
rewards: AoEpochDistributionRewards;
totalEligibleGateways: number;
totalEligibleRewards: number;
totalEligibleObserverReward: number;
totalEligibleGatewayReward: number;
Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/cjs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,16 @@ describe('IO', async () => {
assert.ok(arns);
});

it('should be able to get the current epoch', async () => {
it('should be able to get the current epoch using getCurrentEpoch', async () => {
const epoch = await io.getCurrentEpoch();
assert.ok(epoch);
});

it('should be able to get the current epoch using getEpoch', async () => {
const epoch = await io.getEpoch({ epochIndex: 0 });
assert.ok(epoch);
});

it('should be able to get epoch-settings', async () => {
const epochSettings = await io.getEpochSettings();
assert.ok(epochSettings);
Expand Down
41 changes: 33 additions & 8 deletions tests/e2e/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ describe('e2e tests', () => {
});
});


describe('ANTRegistry', async () => {
const registry = ANTRegistry.init();
const address = '7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk';
Expand All @@ -356,14 +357,38 @@ describe('e2e tests', () => {
assert(Array.isArray(affiliatedAnts.Controlled));
});

it('should be able to create AoANTRegistryWriteable with valid signers', async () => {
for (const signer of signers) {
const registry = ANTRegistry.init({
signer,
});
assert(registry instanceof AoANTRegistryWriteable);
}
});
it('should be able to get current epoch distributions', async () => {
const distributions = await io.getDistributions();
assert.ok(distributions);
});

it('should be able to get epoch distributions at a specific epoch', async () => {
const distributions = await io.getDistributions({ epochIndex: 0 });
assert.ok(distributions);
});

it('should be able to get current epoch observations', async () => {
const observations = await io.getObservations();
assert.ok(observations);
});

it('should be able to get epoch observations at a specific epoch', async () => {
const observations = await io.getObservations({ epochIndex: 0 });
assert.ok(observations);
});

it('should be able to get current demand factor', async () => {
const demandFactor = await io.getDemandFactor();
assert.ok(demandFactor);
});

it('should be able to create IOWriteable with valid signers', async () => {
for (const signer of signers) {
const registry = ANTRegistry.init({
signer,
});
assert(registry instanceof AoANTRegistryWriteable);
}
});

describe('ANT', async () => {
Expand Down

0 comments on commit 789c027

Please sign in to comment.