Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/alpha' into PE-6929-validate-ant…
Browse files Browse the repository at this point in the history
…-read
  • Loading branch information
atticusofsparta committed Oct 16, 2024
2 parents e39c2e1 + c404cb8 commit 2a95bf7
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [2.3.2-alpha.3](https://github.com/ar-io/ar-io-sdk/compare/v2.3.2-alpha.2...v2.3.2-alpha.3) (2024-10-15)


### Bug Fixes

* **types:** add `totalEligibleGateways` to `AoEpochDistributionData` type ([9a35d39](https://github.com/ar-io/ar-io-sdk/commit/9a35d39ed811076a03a392cd5ac7b8f2ce878d98))

## [2.3.2-alpha.2](https://github.com/ar-io/ar-io-sdk/compare/v2.3.2-alpha.1...v2.3.2-alpha.2) (2024-10-15)


Expand Down
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ar.io/sdk",
"version": "2.3.2-alpha.2",
"version": "2.3.2-alpha.3",
"repository": {
"type": "git",
"url": "git+https://github.com/ar-io/ar-io-sdk.git"
Expand Down
1 change: 1 addition & 0 deletions src/types/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export type AoEpochDistributionRewards = {

export type AoEpochDistributionData = {
rewards: AoEpochDistributionRewards;
totalEligibleGateways: number;
totalEligibleRewards: number;
totalEligibleObserverReward: number;
totalEligibleGatewayReward: number;
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

// AUTOMATICALLY GENERATED FILE - DO NOT TOUCH

export const version = '2.3.2-alpha.2';
export const version = '2.3.2-alpha.3';
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
25 changes: 25 additions & 0 deletions tests/e2e/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,31 @@ describe('IO', async () => {
}
});

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 io = IO.init({ signer });
Expand Down

0 comments on commit 2a95bf7

Please sign in to comment.