@show-karma/karma-gap-sdk 0.1.36 → 0.1.37

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.
@@ -1,8 +1,8 @@
1
- import { Hex, IAttestation, TSchemaName } from "core/types";
2
- import { Attestation } from "./Attestation";
3
- import { Community, Grant, MemberOf, Milestone, Project } from "./entities";
4
- import { Grantee } from "./types/attestations";
5
- import { AxiosGQL } from "./GraphQL/AxiosGQL";
1
+ import { Hex, IAttestation, TSchemaName } from 'core/types';
2
+ import { Attestation } from './Attestation';
3
+ import { Community, Grant, MemberOf, Milestone, Project } from './entities';
4
+ import { Grantee } from './types/attestations';
5
+ import { AxiosGQL } from './GraphQL/AxiosGQL';
6
6
  export declare abstract class Fetcher extends AxiosGQL {
7
7
  /**
8
8
  * Fetch a single attestation by its UID.
@@ -129,4 +129,10 @@ export declare abstract class Fetcher extends AxiosGQL {
129
129
  * @returns
130
130
  */
131
131
  abstract slugExists(slug: string): Promise<boolean>;
132
+ /**
133
+ * Get grants for a project by an external uid
134
+ * > Works only for the indexed projects
135
+ * @param projectExtId
136
+ */
137
+ abstract grantsForExtProject(projectExtId: string): Promise<Grant[]>;
132
138
  }
@@ -59,5 +59,6 @@ export declare class GapEasClient extends Fetcher {
59
59
  * @param value
60
60
  */
61
61
  private getSearchFieldString;
62
+ grantsForExtProject(projectExtId: string): Promise<Grant[]>;
62
63
  }
63
64
  export {};
@@ -416,5 +416,9 @@ class GapEasClient extends Fetcher_1.Fetcher {
416
416
  String.raw `\\\\\"${field}\\\\\": \\\\\"${value}\\\\\"`,
417
417
  ];
418
418
  }
419
+ async grantsForExtProject(projectExtId) {
420
+ console.error(new Error('Grants for external project is only supported by a custom indexer. Check https://github.com/show-karma/karma-gap-sdk for more information.'));
421
+ return [];
422
+ }
419
423
  }
420
424
  exports.GapEasClient = GapEasClient;
@@ -1,9 +1,9 @@
1
- import { TSchemaName, IAttestation } from "core/types";
2
- import { Attestation } from "../Attestation";
3
- import { GapSchema } from "../GapSchema";
4
- import { Fetcher } from "../Fetcher";
5
- import { Community, Project, Grant, Milestone, MemberOf } from "../entities";
6
- import { Grantee } from "../types/attestations";
1
+ import { TSchemaName, IAttestation } from 'core/types';
2
+ import { Attestation } from '../Attestation';
3
+ import { GapSchema } from '../GapSchema';
4
+ import { Fetcher } from '../Fetcher';
5
+ import { Community, Project, Grant, Milestone, MemberOf } from '../entities';
6
+ import { Grantee } from '../types/attestations';
7
7
  export declare class GapIndexerClient extends Fetcher {
8
8
  attestation<T = unknown>(uid: `0x${string}`): Promise<Attestation<T, GapSchema>>;
9
9
  attestations(schemaName: TSchemaName, search?: string): Promise<IAttestation[]>;
@@ -21,6 +21,7 @@ export declare class GapIndexerClient extends Fetcher {
21
21
  grantees(): Promise<Grantee[]>;
22
22
  grantsOf(grantee: `0x${string}`, withCommunity?: boolean): Promise<Grant[]>;
23
23
  grantsFor(projects: Project[], withCommunity?: boolean): Promise<Grant[]>;
24
+ grantsForExtProject(projectExtId: string): Promise<Grant[]>;
24
25
  grantsByCommunity(uid: `0x${string}`): Promise<Grant[]>;
25
26
  milestonesOf(grants: Grant[]): Promise<Milestone[]>;
26
27
  membersOf(projects: Project[]): Promise<MemberOf[]>;
@@ -7,26 +7,27 @@ const Fetcher_1 = require("../Fetcher");
7
7
  const entities_1 = require("../entities");
8
8
  const Endpoints = {
9
9
  attestations: {
10
- all: () => "/attestations",
10
+ all: () => '/attestations',
11
11
  byUid: (uid) => `/attestations/${uid}`,
12
12
  },
13
13
  communities: {
14
- all: () => "/communities",
14
+ all: () => '/communities',
15
15
  byUidOrSlug: (uidOrSlug) => `/communities/${uidOrSlug}`,
16
16
  grants: (uidOrSlug) => `/communities/${uidOrSlug}/grants`,
17
17
  },
18
18
  grantees: {
19
- all: () => "/grantees",
19
+ all: () => '/grantees',
20
20
  byAddress: (address) => `/grantees/${address}`,
21
21
  grants: (address) => `/grantees/${address}/grants`,
22
22
  projects: (address) => `/grantees/${address}/projects`,
23
23
  },
24
24
  grants: {
25
- all: () => "/grants",
25
+ all: () => '/grants',
26
26
  byUid: (uid) => `/grants/${uid}`,
27
+ byExternalId: (id) => `/grants/external-id/${id}`,
27
28
  },
28
29
  project: {
29
- all: () => "/projects",
30
+ all: () => '/projects',
30
31
  byUidOrSlug: (uidOrSlug) => `/projects/${uidOrSlug}`,
31
32
  grants: (uidOrSlug) => `/projects/${uidOrSlug}/grants`,
32
33
  milestones: (uidOrSlug) => `/projects/${uidOrSlug}/milestones`,
@@ -36,14 +37,14 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
36
37
  async attestation(uid) {
37
38
  const { data } = await this.client.get(Endpoints.attestations.byUid(uid));
38
39
  if (!data)
39
- throw new Error("Attestation not found");
40
+ throw new Error('Attestation not found');
40
41
  return Attestation_1.Attestation.fromInterface([data])[0];
41
42
  }
42
43
  async attestations(schemaName, search) {
43
44
  const { data } = await this.client.get(Endpoints.attestations.all(), {
44
45
  params: {
45
- "filter[schemaUID]": GapSchema_1.GapSchema.get(schemaName).uid,
46
- "filter[data]": search,
46
+ 'filter[schemaUID]': GapSchema_1.GapSchema.get(schemaName).uid,
47
+ 'filter[data]': search,
47
48
  },
48
49
  });
49
50
  return data || [];
@@ -51,8 +52,8 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
51
52
  async attestationsOf(schemaName, attester) {
52
53
  const { data } = await this.client.get(Endpoints.attestations.all(), {
53
54
  params: {
54
- "filter[schemaUID]": GapSchema_1.GapSchema.get(schemaName).uid,
55
- "filter[recipient]": attester,
55
+ 'filter[schemaUID]': GapSchema_1.GapSchema.get(schemaName).uid,
56
+ 'filter[recipient]': attester,
56
57
  },
57
58
  });
58
59
  return data || [];
@@ -63,13 +64,13 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
63
64
  async communities(search) {
64
65
  const { data } = await this.client.get(Endpoints.communities.all(), {
65
66
  params: {
66
- "filter[name]": search,
67
+ 'filter[name]': search,
67
68
  },
68
69
  });
69
70
  return entities_1.Community.from(data);
70
71
  }
71
72
  communitiesByIds(uids) {
72
- throw new Error("Method not implemented.");
73
+ throw new Error('Method not implemented.');
73
74
  }
74
75
  async communityBySlug(slug) {
75
76
  const { data } = await this.client.get(Endpoints.communities.byUidOrSlug(slug));
@@ -88,7 +89,7 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
88
89
  async projects(name) {
89
90
  const { data } = await this.client.get(Endpoints.project.all(), {
90
91
  params: {
91
- "filter[title]": name,
92
+ 'filter[title]': name,
92
93
  },
93
94
  });
94
95
  return entities_1.Project.from(data);
@@ -113,6 +114,10 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
113
114
  const { data } = await this.client.get(Endpoints.project.grants(projects[0].uid));
114
115
  return entities_1.Grant.from(data);
115
116
  }
117
+ async grantsForExtProject(projectExtId) {
118
+ const { data } = await this.client.get(Endpoints.grants.byExternalId(projectExtId));
119
+ return entities_1.Grant.from(data);
120
+ }
116
121
  async grantsByCommunity(uid) {
117
122
  const { data } = await this.client.get(Endpoints.communities.grants(uid));
118
123
  return entities_1.Grant.from(data);
@@ -122,7 +127,7 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
122
127
  return entities_1.Milestone.from(data);
123
128
  }
124
129
  async membersOf(projects) {
125
- throw new Error("Method not implemented.");
130
+ throw new Error('Method not implemented.');
126
131
  }
127
132
  async slugExists(slug) {
128
133
  try {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.36",
6
+ "version": "0.1.37",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "dist/index.js",
9
9
  "author": "KarmaHQ",