easctl 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easctl",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI tool for the Ethereum Attestation Service — create, revoke, and query attestations from the command line",
5
5
  "bin": {
6
6
  "easctl": "./dist/index.js"
@@ -5,6 +5,7 @@ vi.mock('../../graphql.js', () => ({
5
5
  QUERIES: {
6
6
  getAttestationsBySchema: 'query BySchema',
7
7
  getAttestationsByAttester: 'query ByAttester',
8
+ getAttestationsByRecipient: 'query ByRecipient',
8
9
  },
9
10
  }));
10
11
 
@@ -62,6 +63,20 @@ describe('query-attestations command', () => {
62
63
  });
63
64
  });
64
65
 
66
+ it('queries by recipient', async () => {
67
+ (graphqlQuery as any).mockResolvedValue({
68
+ attestations: [{ id: '0x1' }],
69
+ });
70
+
71
+ await runCommand(['-r', '0xRecipient']);
72
+
73
+ expect(graphqlQuery).toHaveBeenCalledWith('ethereum', QUERIES.getAttestationsByRecipient, {
74
+ recipient: '0xRecipient',
75
+ take: 10,
76
+ skip: 0,
77
+ });
78
+ });
79
+
65
80
  it('passes skip for pagination', async () => {
66
81
  (graphqlQuery as any).mockResolvedValue({ attestations: [] });
67
82
 
@@ -65,6 +65,16 @@ describe('GraphQL live queries (sepolia)', () => {
65
65
  expect(Array.isArray(data.attestations)).toBe(true);
66
66
  });
67
67
 
68
+ it('getAttestationsByRecipient returns attestations array', async () => {
69
+ const data = await graphqlQuery(chain, QUERIES.getAttestationsByRecipient, {
70
+ recipient: '0x0000000000000000000000000000000000000000',
71
+ take: 1,
72
+ });
73
+
74
+ expect(data.attestations).toBeDefined();
75
+ expect(Array.isArray(data.attestations)).toBe(true);
76
+ });
77
+
68
78
  it('getAttestation returns a single attestation with all expected fields', async () => {
69
79
  // First get a real attestation ID by querying recent attestations by a known schema
70
80
  // We use getSchemata to find a schema, then query its attestations
@@ -7,16 +7,18 @@ export const queryAttestationsCommand = new Command('query-attestations')
7
7
  .description('Query attestations by schema or attester from the EAS GraphQL API')
8
8
  .option('-s, --schema <uid>', 'Filter by schema UID or popular schema name')
9
9
  .option('-a, --attester <address>', 'Filter by attester address')
10
+ .option('-r, --recipient <address>', 'Filter by recipient address')
10
11
  .option('-n, --limit <number>', 'Max results to return', '10')
11
12
  .option('--skip <number>', 'Number of results to skip (for pagination)', '0')
12
13
  .option('-c, --chain <name>', 'Chain name', 'ethereum')
13
14
  .action(async (opts) => {
14
15
  try {
15
- if (!opts.schema && !opts.attester) {
16
- throw new Error('Provide at least one filter: --schema or --attester');
16
+ if (!opts.schema && !opts.attester && !opts.recipient) {
17
+ throw new Error('Provide at least one filter: --schema, --attester, or --recipient');
17
18
  }
18
19
  if (opts.schema) opts.schema = resolveAndValidateSchemaUID(opts.schema, 'schema UID');
19
20
  if (opts.attester) validateAddress(opts.attester, 'attester');
21
+ if (opts.recipient) validateAddress(opts.recipient, 'recipient');
20
22
 
21
23
  const take = parseInt(opts.limit, 10);
22
24
  const skip = parseInt(opts.skip, 10);
@@ -30,12 +32,18 @@ export const queryAttestationsCommand = new Command('query-attestations')
30
32
  take,
31
33
  skip,
32
34
  });
33
- } else {
35
+ } else if (opts.attester) {
34
36
  data = await graphqlQuery(opts.chain, QUERIES.getAttestationsByAttester, {
35
37
  attester: opts.attester,
36
38
  take,
37
39
  skip,
38
40
  });
41
+ } else {
42
+ data = await graphqlQuery(opts.chain, QUERIES.getAttestationsByRecipient, {
43
+ recipient: opts.recipient,
44
+ take,
45
+ skip,
46
+ });
39
47
  }
40
48
 
41
49
  const attestations = data.attestations || [];
package/src/graphql.ts CHANGED
@@ -117,6 +117,24 @@ export const QUERIES = {
117
117
  }
118
118
  }
119
119
  `,
120
+ getAttestationsByRecipient: `
121
+ query GetAttestationsByRecipient($recipient: String!, $take: Int, $skip: Int) {
122
+ attestations(
123
+ where: { recipient: { equals: $recipient } }
124
+ take: $take
125
+ skip: $skip
126
+ orderBy: [{ time: desc }]
127
+ ) {
128
+ id
129
+ attester
130
+ schemaId
131
+ time
132
+ revoked
133
+ decodedDataJson
134
+ isOffchain
135
+ }
136
+ }
137
+ `,
120
138
  getSchemata: `
121
139
  query GetSchemata($take: Int, $skip: Int) {
122
140
  schemata(