Skip to content

Commit

Permalink
fix(ant): add priority as an attribute on ANTs
Browse files Browse the repository at this point in the history
ANTs can optionally provide a priority order of their records. This is how ar-io gateways will enforce undername limits. If no priority order is provided, records will be sorted lexigraphically
  • Loading branch information
dtfiedler authored and dtfiedler committed Feb 4, 2025
1 parent 064f574 commit f0c6758
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/types/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const AntKeywordsSchema = z.array(z.string()); // TODO: add specific limi
export const AntRecordSchema = z.object({
transactionId: ArweaveTxIdSchema.describe('The Target ID of the undername'),
ttlSeconds: z.number(),
priority: z.number().optional(),
});
export type AoANTRecord = z.infer<typeof AntRecordSchema>;
export const AntRecordsSchema = z.record(z.string(), AntRecordSchema);
Expand Down Expand Up @@ -239,6 +240,7 @@ export interface AoANTWrite extends AoANTRead {
export type AoANTSetBaseNameRecordParams = {
transactionId: string;
ttlSeconds: number;
priority?: number;
};

export type AoANTSetUndernameRecordParams = AoANTSetBaseNameRecordParams & {
Expand Down
8 changes: 7 additions & 1 deletion tests/e2e/esm/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,13 @@ describe('e2e esm tests', async () => {
it('should be able to get the ANT records', async () => {
const records = await ant.getRecords();
assert.ok(records);
// TODO: check enforcement of alphabetical order with '@' first
for (const record of Object.values(records)) {
assert(typeof record.transactionId === 'string');
assert(typeof record.ttlSeconds === 'number');
if (record.priority) {
assert(typeof record.priority === 'number');
}
}
});

it('should be able to get a @ record from the ANT', async () => {
Expand Down

0 comments on commit f0c6758

Please sign in to comment.