@show-karma/karma-gap-sdk 0.4.22 → 0.4.23

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.
@@ -67,10 +67,10 @@ class Project extends Attestation_1.Attestation {
67
67
  return { tx: txArray, uids: [this.uid] };
68
68
  }
69
69
  isOwner(signer, publicAddress) {
70
- return GapContract_1.GapContract.isProjectOwner(signer, this.uid, this.chainID, publicAddress);
70
+ return GapContract_1.GapContract.isProjectOwner(signer, this.uid, this.chainID, publicAddress, this.schema.gap.rpcConfig);
71
71
  }
72
72
  isAdmin(signer, publicAddress) {
73
- return GapContract_1.GapContract.isProjectAdmin(signer, this.uid, this.chainID, publicAddress);
73
+ return GapContract_1.GapContract.isProjectAdmin(signer, this.uid, this.chainID, publicAddress, this.schema.gap.rpcConfig);
74
74
  }
75
75
  /**
76
76
  * Add new members to the project.
@@ -2,72 +2,72 @@ import { AxiosGQL } from "../../GraphQL/AxiosGQL";
2
2
  import { Hex, IAttestationResponse, ICommunityResponse, ICommunityAdminsResponse, IGrantResponse, IProjectResponse, ISearchResponse, IProjectMilestoneResponse, ITrackResponse, ITrackAssignmentResponse, IProjectTrackResponse } from "./types";
3
3
  export declare class GapIndexerApi extends AxiosGQL {
4
4
  constructor(url: string);
5
- attestation(uid: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse, any, {}>>;
6
- attestations(schemaUID: string, search?: string): Promise<import("axios").AxiosResponse<IAttestationResponse[], any, {}>>;
7
- attestationsOf(schemaUID: string, attester: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse[], any, {}>>;
5
+ attestation(uid: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse, any>>;
6
+ attestations(schemaUID: string, search?: string): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
7
+ attestationsOf(schemaUID: string, attester: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
8
8
  /**
9
9
  * Community
10
10
  */
11
- communities(search?: string): Promise<import("axios").AxiosResponse<ICommunityResponse[], any, {}>>;
12
- communitiesOf(address: Hex, withGrants: boolean): Promise<import("axios").AxiosResponse<ICommunityResponse[], any, {}>>;
13
- adminOf(address: Hex): Promise<import("axios").AxiosResponse<ICommunityResponse[], any, {}>>;
14
- communityBySlug(slug: string): Promise<import("axios").AxiosResponse<ICommunityResponse, any, {}>>;
15
- communityAdmins(uid: Hex): Promise<import("axios").AxiosResponse<ICommunityAdminsResponse, any, {}>>;
11
+ communities(search?: string): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
12
+ communitiesOf(address: Hex, withGrants: boolean): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
13
+ adminOf(address: Hex): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
14
+ communityBySlug(slug: string): Promise<import("axios").AxiosResponse<ICommunityResponse, any>>;
15
+ communityAdmins(uid: Hex): Promise<import("axios").AxiosResponse<ICommunityAdminsResponse, any>>;
16
16
  /**
17
17
  * Project
18
18
  */
19
- projectBySlug(slug: string): Promise<import("axios").AxiosResponse<IProjectResponse, any, {}>>;
20
- search(query: string): Promise<import("axios").AxiosResponse<ISearchResponse, any, {}>>;
21
- searchProjects(query: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any, {}>>;
22
- projects(name?: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any, {}>>;
23
- projectsOf(grantee: Hex): Promise<import("axios").AxiosResponse<IProjectResponse[], any, {}>>;
24
- projectMilestones(uidOrSlug: string): Promise<import("axios").AxiosResponse<IProjectMilestoneResponse[], any, {}>>;
19
+ projectBySlug(slug: string): Promise<import("axios").AxiosResponse<IProjectResponse, any>>;
20
+ search(query: string): Promise<import("axios").AxiosResponse<ISearchResponse, any>>;
21
+ searchProjects(query: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
22
+ projects(name?: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
23
+ projectsOf(grantee: Hex): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
24
+ projectMilestones(uidOrSlug: string): Promise<import("axios").AxiosResponse<IProjectMilestoneResponse[], any>>;
25
25
  /**
26
26
  * Grantee
27
27
  */
28
- grantee(address: Hex): Promise<import("axios").AxiosResponse<any, any, {}>>;
28
+ grantee(address: Hex): Promise<import("axios").AxiosResponse<any, any>>;
29
29
  grantees(): Promise<import("axios").AxiosResponse<{
30
30
  [key: `0x${string}`]: {
31
31
  grants: number;
32
32
  projects: number;
33
33
  };
34
- }, any, {}>>;
34
+ }, any>>;
35
35
  /**
36
36
  * Grant
37
37
  */
38
- grantsOf(grantee: Hex, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any, {}>>;
39
- grantsFor(uid: string, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any, {}>>;
40
- grantsForExtProject(projectExtId: string): Promise<import("axios").AxiosResponse<IGrantResponse[], any, {}>>;
41
- grantBySlug(slug: Hex): Promise<import("axios").AxiosResponse<IGrantResponse, any, {}>>;
38
+ grantsOf(grantee: Hex, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
39
+ grantsFor(uid: string, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
40
+ grantsForExtProject(projectExtId: string): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
41
+ grantBySlug(slug: Hex): Promise<import("axios").AxiosResponse<IGrantResponse, any>>;
42
42
  grantsByCommunity(uid: Hex, page?: number, pageLimit?: number): Promise<import("axios").AxiosResponse<{
43
43
  data: IGrantResponse[];
44
- }, any, {}>>;
44
+ }, any>>;
45
45
  /**
46
46
  * Milestone
47
47
  */
48
- milestonesOf(uid: Hex): Promise<import("axios").AxiosResponse<any, any, {}>>;
48
+ milestonesOf(uid: Hex): Promise<import("axios").AxiosResponse<any, any>>;
49
49
  slugExists(slug: string): Promise<boolean>;
50
50
  /**
51
51
  * Tracks
52
52
  */
53
- getTracks(communityUID: string, includeArchived?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any, {}>>;
54
- getTrackById(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
53
+ getTracks(communityUID: string, includeArchived?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
54
+ getTrackById(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
55
55
  createTrack(data: {
56
56
  name: string;
57
57
  description?: string;
58
58
  communityUID: string;
59
- }): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
59
+ }): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
60
60
  updateTrack(id: string, data: {
61
61
  name?: string;
62
62
  description?: string;
63
63
  communityUID?: string;
64
- }): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
65
- archiveTrack(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
66
- assignTracksToProgram(programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse[], any, {}>>;
67
- unassignTrackFromProgram(programId: string, trackId: string): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse, any, {}>>;
68
- getTracksForProgram(programId: string): Promise<import("axios").AxiosResponse<ITrackResponse[], any, {}>>;
69
- getTracksForProject(projectId: string, programId: string, activeOnly?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any, {}>>;
70
- assignTracksToProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any, {}>>;
71
- unassignTracksFromProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any, {}>>;
72
- getProjectsByTrack(communityId: string, programId: string, trackId?: string): Promise<import("axios").AxiosResponse<IProjectTrackResponse[], any, {}>>;
64
+ }): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
65
+ archiveTrack(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
66
+ assignTracksToProgram(programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse[], any>>;
67
+ unassignTrackFromProgram(programId: string, trackId: string): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse, any>>;
68
+ getTracksForProgram(programId: string): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
69
+ getTracksForProject(projectId: string, programId: string, activeOnly?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
70
+ assignTracksToProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any>>;
71
+ unassignTracksFromProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any>>;
72
+ getProjectsByTrack(communityId: string, programId: string, trackId?: string): Promise<import("axios").AxiosResponse<IProjectTrackResponse[], any>>;
73
73
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.4.22",
6
+ "version": "0.4.23",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "./index.js",
9
9
  "author": "KarmaHQ",
@@ -1,23 +0,0 @@
1
- import { RemoteStorage } from "./RemoteStorage";
2
- import { TRemoteStorageOutput } from "core/types";
3
- export interface IpfsStorageOptions {
4
- token: string;
5
- }
6
- export declare class IpfsStorage extends RemoteStorage {
7
- private pinataJWTToken;
8
- constructor(opts: IpfsStorageOptions,
9
- /**
10
- * If set, will send request to another server instead of
11
- * using the local instance
12
- */
13
- sponsor?: RemoteStorage["sponsor"]);
14
- private assert;
15
- save<T = unknown>(data: T): Promise<string>;
16
- encode(data: string): TRemoteStorageOutput<string>;
17
- get<T = unknown>(args: {
18
- cid: string;
19
- }): Promise<T>;
20
- saveAndGetCID(data: any, pinataMetadata?: {
21
- name: string;
22
- }): Promise<any>;
23
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IpfsStorage = void 0;
7
- const RemoteStorage_1 = require("./RemoteStorage");
8
- const SchemaError_1 = require("../SchemaError");
9
- const utils_1 = require("../../utils");
10
- const axios_1 = __importDefault(require("axios"));
11
- class IpfsStorage extends RemoteStorage_1.RemoteStorage {
12
- constructor(opts,
13
- /**
14
- * If set, will send request to another server instead of
15
- * using the local instance
16
- */
17
- sponsor) {
18
- super(0 /* STORAGE_TYPE.IPFS */, sponsor);
19
- this.assert(opts);
20
- this.pinataJWTToken = opts.token;
21
- }
22
- assert(opts) { }
23
- async save(data) {
24
- try {
25
- const cid = await this.saveAndGetCID(data);
26
- return cid;
27
- }
28
- catch (error) {
29
- throw new SchemaError_1.RemoteStorageError("REMOTE_STORAGE_UPLOAD", `Error adding data to IPFS`);
30
- }
31
- }
32
- encode(data) {
33
- return { hash: data, storageType: this.storageType };
34
- }
35
- async get(args) {
36
- return (0, utils_1.getIPFSData)(args.cid);
37
- }
38
- async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
39
- try {
40
- const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
41
- pinataContent: data,
42
- pinataMetadata: pinataMetadata,
43
- }, {
44
- headers: {
45
- "Content-Type": "application/json",
46
- Authorization: `Bearer ${this.pinataJWTToken}`,
47
- },
48
- });
49
- return res.data.IpfsHash;
50
- }
51
- catch (error) {
52
- throw new SchemaError_1.RemoteStorageError("REMOTE_STORAGE_UPLOAD", `Error adding data to IPFS`);
53
- }
54
- }
55
- }
56
- exports.IpfsStorage = IpfsStorage;
@@ -1,41 +0,0 @@
1
- import { STORAGE_TYPE, TRemoteStorageOutput } from 'core/types';
2
- interface SponsoredRemote {
3
- url: string;
4
- responseParser: (response: any) => string;
5
- }
6
- export declare abstract class RemoteStorage<C = unknown> {
7
- protected client: C;
8
- readonly storageType: number;
9
- readonly sponsor?: SponsoredRemote;
10
- constructor(storageType: STORAGE_TYPE,
11
- /**
12
- * If set, will try to POST request to another server instead of
13
- * using the local instance.
14
- *
15
- * > If a response parser is not set, it will try to get { cid: string }.
16
- */
17
- sponsor: SponsoredRemote);
18
- /**
19
- * Try to save data to remote storage and return the CID.
20
- * IF sponsorUrl is set, this method will be automatically
21
- * intercepted and will send a POST request to the sponsorUrl
22
- * with the contents: `{ data: T, type: "<AttestationType>" }`
23
- */
24
- abstract save<T = unknown>(data: T, schemaName: string): Promise<string>;
25
- /**
26
- * Encodes the data according to the remote storage type parameters
27
- * OR returns the data as is if no encoding is required
28
- */
29
- abstract encode(data: unknown): TRemoteStorageOutput;
30
- /**
31
- * Get data from Remote Storage
32
- */
33
- abstract get<T = unknown>(args: unknown): Promise<T>;
34
- /**
35
- * If sponsorUrl is set, intercept the save method and send a POST request
36
- * to the sponsorUrl instead of using the local instance.
37
- * @returns
38
- */
39
- private interceptRemoteStorage;
40
- }
41
- export {};
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RemoteStorage = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- class RemoteStorage {
9
- constructor(storageType,
10
- /**
11
- * If set, will try to POST request to another server instead of
12
- * using the local instance.
13
- *
14
- * > If a response parser is not set, it will try to get { cid: string }.
15
- */
16
- sponsor) {
17
- this.storageType = storageType;
18
- this.sponsor = sponsor;
19
- this.interceptRemoteStorage();
20
- }
21
- /**
22
- * If sponsorUrl is set, intercept the save method and send a POST request
23
- * to the sponsorUrl instead of using the local instance.
24
- * @returns
25
- */
26
- interceptRemoteStorage() {
27
- if (!this.sponsor?.url)
28
- return;
29
- this.save = async (data, schemaName) => {
30
- const { data: response } = await axios_1.default.post(this.sponsor.url, {
31
- data: data,
32
- type: schemaName,
33
- });
34
- return this.sponsor.responseParser?.(response) || response.cid;
35
- };
36
- }
37
- }
38
- exports.RemoteStorage = RemoteStorage;
@@ -1 +0,0 @@
1
- export declare function getIPFSData<T>(cid: string): Promise<T>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getIPFSData = getIPFSData;
7
- const axios_1 = __importDefault(require("axios"));
8
- async function getIPFSData(cid) {
9
- try {
10
- const { data } = await axios_1.default.get(`https://ipfs.io/ipfs/${cid}`, {
11
- timeout: 5000,
12
- });
13
- return data;
14
- }
15
- catch (err) {
16
- console.error(err);
17
- throw new Error(`Error to retrive data for CID: ${cid}`);
18
- }
19
- }