Skip to content

Commit

Permalink
Merge pull request #291 from ar-io/primary-name-cost
Browse files Browse the repository at this point in the history
fix(primary): support primary name in token cost API
  • Loading branch information
dtfiedler authored Nov 28, 2024
2 parents 2b6775b + 8fb1f24 commit cf70387
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1577,13 +1577,15 @@ const observers = await io.getPrescribedObservers({ epochIndex: 0 });

#### `getPrimaryNames({ cursor, limit, sortBy, sortOrder })`

Retrieves all primary names across all gateways, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last name from the previous request.
Retrieves all primary names paginated and sorted by the specified criteria. The `cursor` used for pagination is the last name from the previous request.

```typescript
const io = IO.init();
const names = await io.getPrimaryNames({
cursor: 'ar-io',
limit: 2,
cursor: 'ao', // this is the last name from the previous request
limit: 1,
sortBy: 'startTimestamp',
sortOrder: 'desc',
});
```

Expand All @@ -1593,10 +1595,10 @@ const names = await io.getPrimaryNames({
```json
{
"sortOrder": "desc",
"hasMore": false,
"totalItems": 1,
"limit": 100,
"sortBy": "name",
"hasMore": true,
"totalItems": 100,
"limit": 1,
"sortBy": "startTimestamp",
"items": [
{
"owner": "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
Expand Down
17 changes: 15 additions & 2 deletions src/common/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,17 +454,30 @@ export class IOReadable implements AoIORead {
quantity: number;
name: string;
}): Promise<number>;
async getTokenCost(params: {
intent: 'Upgrade-Name';
name: string;
}): Promise<number>;
async getTokenCost(params: {
intent: 'Primary-Name-Request';
name: string;
}): Promise<number>;
async getTokenCost({
intent,
type,
years,
name,
quantity,
}: {
intent: 'Buy-Record' | 'Extend-Lease' | 'Increase-Undername-Limit';
intent:
| 'Buy-Record'
| 'Extend-Lease'
| 'Increase-Undername-Limit'
| 'Upgrade-Name'
| 'Primary-Name-Request';
type?: 'permabuy' | 'lease';
years?: number;
name?: string;
name: string;
quantity?: number;
}): Promise<number> {
const allTags = [
Expand Down
11 changes: 8 additions & 3 deletions src/types/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,17 @@ export interface AoIORead {
name,
quantity,
}: {
intent: 'Buy-Record' | 'Extend-Lease' | 'Increase-Undername-Limit';
intent:
| 'Buy-Record'
| 'Extend-Lease'
| 'Increase-Undername-Limit'
| 'Upgrade-Name'
| 'Primary-Name-Request';
type?: 'permabuy' | 'lease';
years?: number;
name?: string;
name: string;
quantity?: number;
}): Promise<number>;
}): Promise<number>; // TODO: add getCostDetails API that provides funding cost and discount details
getRegistrationFees(): Promise<AoRegistrationFees>;
getDemandFactor(): Promise<number>;
getVaults(
Expand Down

0 comments on commit cf70387

Please sign in to comment.