@show-karma/karma-gap-sdk 0.4.16 → 0.4.18
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/core/abi/AirdropNFT.json +1 -1
- package/core/abi/Allo.json +860 -860
- package/core/abi/AlloRegistry.json +578 -578
- package/core/abi/CommunityResolverABI.json +506 -506
- package/core/abi/Donations.json +251 -251
- package/core/abi/EAS.json +1 -1
- package/core/abi/MultiAttester.json +746 -746
- package/core/abi/ProjectResolver.json +574 -574
- package/core/abi/SchemaRegistry.json +1 -1
- package/core/abi/index.d.ts +1114 -0
- package/core/abi/index.js +26 -0
- package/core/class/AllGapSchemas.d.ts +9 -0
- package/core/class/AllGapSchemas.js +19 -0
- package/core/class/Attestation.d.ts +173 -0
- package/core/class/Attestation.js +333 -0
- package/core/class/Fetcher.d.ts +175 -0
- package/core/class/Fetcher.js +13 -0
- package/core/class/GAP.d.ts +254 -0
- package/core/class/GAP.js +289 -0
- package/core/class/GapSchema.d.ts +34 -0
- package/core/class/GapSchema.js +62 -0
- package/core/class/Gelato/{Gelato.ts → Gelato.js} +0 -23
- package/core/class/GrantProgramRegistry/Allo.d.ts +17 -0
- package/core/class/GrantProgramRegistry/Allo.js +137 -0
- package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +15 -0
- package/core/class/GrantProgramRegistry/AlloRegistry.js +70 -0
- package/core/class/GraphQL/AxiosGQL.d.ts +6 -0
- package/core/class/GraphQL/AxiosGQL.js +25 -0
- package/core/class/GraphQL/EASClient.d.ts +16 -0
- package/core/class/GraphQL/EASClient.js +26 -0
- package/core/class/GraphQL/GapEasClient.d.ts +71 -0
- package/core/class/GraphQL/GapEasClient.js +451 -0
- package/core/class/GraphQL/index.js +19 -0
- package/core/class/Schema.d.ts +233 -0
- package/core/class/Schema.js +490 -0
- package/core/class/SchemaError.d.ts +30 -0
- package/core/class/SchemaError.js +39 -0
- package/core/class/contract/GapContract.d.ts +102 -0
- package/core/class/contract/GapContract.js +285 -0
- package/core/class/entities/Community.d.ts +34 -0
- package/core/class/entities/Community.js +109 -0
- package/core/class/entities/ContributorProfile.d.ts +41 -0
- package/core/class/entities/ContributorProfile.js +69 -0
- package/core/class/entities/Grant.d.ts +54 -0
- package/core/class/entities/Grant.js +223 -0
- package/core/class/entities/GrantUpdate.d.ts +62 -0
- package/core/class/entities/GrantUpdate.js +114 -0
- package/core/class/entities/MemberOf.d.ts +11 -0
- package/core/class/entities/MemberOf.js +33 -0
- package/core/class/entities/Milestone.d.ts +168 -0
- package/core/class/entities/Milestone.js +657 -0
- package/core/class/entities/Project.d.ts +92 -0
- package/core/class/entities/Project.js +418 -0
- package/core/class/entities/ProjectImpact.d.ts +50 -0
- package/core/class/entities/ProjectImpact.js +112 -0
- package/core/class/entities/ProjectMilestone.d.ts +60 -0
- package/core/class/entities/ProjectMilestone.js +174 -0
- package/core/class/entities/ProjectPointer.d.ts +12 -0
- package/core/class/entities/ProjectPointer.js +22 -0
- package/core/class/entities/ProjectUpdate.d.ts +50 -0
- package/core/class/entities/ProjectUpdate.js +110 -0
- package/core/class/entities/Track.d.ts +16 -0
- package/core/class/entities/Track.js +21 -0
- package/core/class/entities/index.js +26 -0
- package/core/class/index.js +26 -0
- package/core/class/karma-indexer/GapIndexerClient.d.ts +66 -0
- package/core/class/karma-indexer/GapIndexerClient.js +207 -0
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +73 -0
- package/core/class/karma-indexer/api/GapIndexerApi.js +256 -0
- package/core/class/karma-indexer/api/types.d.ts +309 -0
- package/core/class/karma-indexer/api/types.js +2 -0
- package/core/class/remote-storage/IpfsStorage.d.ts +23 -0
- package/core/class/remote-storage/IpfsStorage.js +56 -0
- package/core/class/remote-storage/RemoteStorage.d.ts +41 -0
- package/core/class/remote-storage/RemoteStorage.js +38 -0
- package/core/class/types/allo.d.ts +78 -0
- package/core/class/types/allo.js +2 -0
- package/core/class/types/attestations.d.ts +173 -0
- package/core/class/types/attestations.js +66 -0
- package/core/consts.d.ts +50 -0
- package/core/consts.js +699 -0
- package/core/index.js +24 -0
- package/core/shared/types.d.ts +13 -0
- package/core/shared/types.js +2 -0
- package/core/types.d.ts +131 -0
- package/core/types.js +13 -0
- package/core/utils/gelato/index.js +19 -0
- package/core/utils/gelato/send-gelato-txn.d.ts +55 -0
- package/core/utils/gelato/send-gelato-txn.js +100 -0
- package/core/utils/gelato/sponsor-handler.d.ts +9 -0
- package/core/utils/gelato/sponsor-handler.js +60 -0
- package/core/utils/gelato/watch-gelato-txn.d.ts +7 -0
- package/core/utils/gelato/watch-gelato-txn.js +63 -0
- package/core/utils/get-date.d.ts +1 -0
- package/core/utils/get-date.js +7 -0
- package/core/utils/get-ipfs-data.d.ts +1 -0
- package/core/utils/get-ipfs-data.js +20 -0
- package/core/utils/get-web3-provider.d.ts +2 -0
- package/core/utils/get-web3-provider.js +18 -0
- package/core/utils/gql-queries.d.ts +12 -0
- package/core/utils/gql-queries.js +90 -0
- package/core/utils/index.js +23 -0
- package/core/utils/map-filter.d.ts +8 -0
- package/core/utils/map-filter.js +20 -0
- package/core/utils/serialize-bigint.d.ts +1 -0
- package/core/utils/serialize-bigint.js +8 -0
- package/core/utils/to-unix.d.ts +1 -0
- package/core/utils/to-unix.js +25 -0
- package/index.js +17 -0
- package/package.json +45 -45
- package/.cursorrules +0 -43
- package/core/abi/index.ts +0 -21
- package/core/class/AllGapSchemas.ts +0 -21
- package/core/class/Attestation.ts +0 -429
- package/core/class/Fetcher.ts +0 -224
- package/core/class/GAP.ts +0 -481
- package/core/class/GapSchema.ts +0 -93
- package/core/class/GrantProgramRegistry/Allo.ts +0 -188
- package/core/class/GrantProgramRegistry/AlloRegistry.ts +0 -101
- package/core/class/GraphQL/AxiosGQL.ts +0 -29
- package/core/class/GraphQL/EASClient.ts +0 -34
- package/core/class/GraphQL/GapEasClient.ts +0 -869
- package/core/class/Schema.ts +0 -659
- package/core/class/SchemaError.ts +0 -42
- package/core/class/contract/GapContract.ts +0 -457
- package/core/class/entities/Community.ts +0 -148
- package/core/class/entities/ContributorProfile.ts +0 -108
- package/core/class/entities/Grant.ts +0 -321
- package/core/class/entities/GrantUpdate.ts +0 -187
- package/core/class/entities/MemberOf.ts +0 -52
- package/core/class/entities/Milestone.ts +0 -898
- package/core/class/entities/Project.ts +0 -672
- package/core/class/entities/ProjectImpact.ts +0 -170
- package/core/class/entities/ProjectMilestone.ts +0 -254
- package/core/class/entities/ProjectPointer.ts +0 -39
- package/core/class/entities/ProjectUpdate.ts +0 -176
- package/core/class/entities/Track.ts +0 -32
- package/core/class/karma-indexer/GapIndexerClient.ts +0 -383
- package/core/class/karma-indexer/api/GapIndexerApi.ts +0 -446
- package/core/class/karma-indexer/api/types.ts +0 -313
- package/core/class/remote-storage/IpfsStorage.ts +0 -76
- package/core/class/remote-storage/RemoteStorage.ts +0 -65
- package/core/class/types/allo.ts +0 -93
- package/core/class/types/attestations.ts +0 -223
- package/core/consts.ts +0 -775
- package/core/scripts/create-grant.ts +0 -102
- package/core/scripts/create-program.ts +0 -43
- package/core/scripts/create-schemas.ts +0 -65
- package/core/scripts/deploy.ts +0 -65
- package/core/scripts/index.ts +0 -1
- package/core/scripts/milestone-multi-grants.ts +0 -125
- package/core/shared/types.ts +0 -13
- package/core/types.ts +0 -224
- package/core/utils/gelato/send-gelato-txn.ts +0 -114
- package/core/utils/gelato/sponsor-handler.ts +0 -77
- package/core/utils/gelato/watch-gelato-txn.ts +0 -67
- package/core/utils/get-date.ts +0 -3
- package/core/utils/get-ipfs-data.ts +0 -13
- package/core/utils/get-web3-provider.ts +0 -18
- package/core/utils/gql-queries.ts +0 -133
- package/core/utils/map-filter.ts +0 -21
- package/core/utils/serialize-bigint.ts +0 -7
- package/core/utils/to-unix.ts +0 -18
- package/create-community-example.ts +0 -119
- package/csv-upload/README.md +0 -74
- package/csv-upload/config.ts +0 -41
- package/csv-upload/example.csv +0 -2
- package/csv-upload/keys.example.json +0 -8
- package/csv-upload/scripts/run.ts +0 -417
- package/csv-upload/types.ts +0 -39
- package/docs/.gitkeep +0 -0
- package/docs/images/attestation-architecture.png +0 -0
- package/docs/images/dfd-get-projects.png +0 -0
- package/gap-schema.yaml +0 -155
- package/milestone-workflow-example.ts +0 -353
- package/readme.md +0 -872
- package/schemas/.gitkeep +0 -0
- package/schemas/GAP-schemas-1692135812877.json +0 -33
- package/test-file-indexer-api.ts +0 -25
- package/tsconfig.json +0 -26
- /package/{csv-upload/.gitkeep → core/class/Gelato/Gelato.d.ts} +0 -0
- /package/core/class/GraphQL/{index.ts → index.d.ts} +0 -0
- /package/core/class/entities/{index.ts → index.d.ts} +0 -0
- /package/core/class/{index.ts → index.d.ts} +0 -0
- /package/core/{index.ts → index.d.ts} +0 -0
- /package/core/utils/gelato/{index.ts → index.d.ts} +0 -0
- /package/core/utils/{index.ts → index.d.ts} +0 -0
- /package/{index.ts → index.d.ts} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { ProfileMetadata } from "../types/allo";
|
|
3
|
+
export declare class AlloRegistry {
|
|
4
|
+
private contract;
|
|
5
|
+
private pinataJWTToken;
|
|
6
|
+
constructor(signer: ethers.Signer, pinataJWTToken: string);
|
|
7
|
+
saveAndGetCID(data: any, pinataMetadata?: {
|
|
8
|
+
name: string;
|
|
9
|
+
}): Promise<any>;
|
|
10
|
+
createProgram(nonce: number, name: string, profileMetadata: ProfileMetadata, owner: string, members: string[]): Promise<{
|
|
11
|
+
profileId: any;
|
|
12
|
+
txHash: any;
|
|
13
|
+
}>;
|
|
14
|
+
updateProgramMetadata(profileId: string, profileMetadata: ProfileMetadata): Promise<any>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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.AlloRegistry = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const AlloRegistry_json_1 = __importDefault(require("../../abi/AlloRegistry.json"));
|
|
9
|
+
const consts_1 = require("../../consts");
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
class AlloRegistry {
|
|
12
|
+
constructor(signer, pinataJWTToken) {
|
|
13
|
+
this.contract = new ethers_1.ethers.Contract(consts_1.AlloContracts.registry, AlloRegistry_json_1.default, signer);
|
|
14
|
+
this.pinataJWTToken = pinataJWTToken;
|
|
15
|
+
}
|
|
16
|
+
async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
|
|
17
|
+
try {
|
|
18
|
+
const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
|
|
19
|
+
pinataContent: data,
|
|
20
|
+
pinataMetadata: pinataMetadata,
|
|
21
|
+
}, {
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
Authorization: `Bearer ${this.pinataJWTToken}`,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return res.data.IpfsHash;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.log(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async createProgram(nonce, name, profileMetadata, owner, members) {
|
|
34
|
+
console.log("Creating program...");
|
|
35
|
+
try {
|
|
36
|
+
const metadata_cid = await this.saveAndGetCID(profileMetadata);
|
|
37
|
+
const metadata = {
|
|
38
|
+
protocol: 1,
|
|
39
|
+
pointer: metadata_cid,
|
|
40
|
+
};
|
|
41
|
+
const tx = await this.contract.createProfile(nonce, name, metadata, owner, members);
|
|
42
|
+
const receipt = await tx.wait();
|
|
43
|
+
// Get ProfileCreated event
|
|
44
|
+
const profileCreatedEvent = receipt.logs.find((event) => event.eventName === "ProfileCreated");
|
|
45
|
+
return {
|
|
46
|
+
profileId: profileCreatedEvent.args[0],
|
|
47
|
+
txHash: receipt.hash,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error(`Failed to register program: ${error}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async updateProgramMetadata(profileId, profileMetadata) {
|
|
55
|
+
try {
|
|
56
|
+
const metadata_cid = await this.saveAndGetCID(profileMetadata);
|
|
57
|
+
const metadata = {
|
|
58
|
+
protocol: 1,
|
|
59
|
+
pointer: metadata_cid,
|
|
60
|
+
};
|
|
61
|
+
const tx = await this.contract.updateProfileMetadata(profileId, metadata);
|
|
62
|
+
const receipt = await tx.wait();
|
|
63
|
+
return receipt;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error(`Failed to update profile metadata: ${error}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.AlloRegistry = AlloRegistry;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.AxiosGQL = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
class AxiosGQL {
|
|
9
|
+
constructor(url) {
|
|
10
|
+
this.client = axios_1.default.create({
|
|
11
|
+
baseURL: url,
|
|
12
|
+
headers: {
|
|
13
|
+
"Content-Type": "application/json",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async query(query, variables) {
|
|
18
|
+
const { data: { data }, } = await this.client.post("", {
|
|
19
|
+
query,
|
|
20
|
+
variables,
|
|
21
|
+
});
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.AxiosGQL = AxiosGQL;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TNetwork } from "../../types";
|
|
2
|
+
import { AxiosGQL } from "./AxiosGQL";
|
|
3
|
+
interface EASClientProps {
|
|
4
|
+
network: TNetwork;
|
|
5
|
+
}
|
|
6
|
+
export declare class EASClient extends AxiosGQL implements EASClientProps {
|
|
7
|
+
private readonly _network;
|
|
8
|
+
constructor(args: EASClientProps);
|
|
9
|
+
/**
|
|
10
|
+
* Validate the constructor arguments
|
|
11
|
+
* @param args
|
|
12
|
+
*/
|
|
13
|
+
private assert;
|
|
14
|
+
get network(): TNetwork;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EASClient = void 0;
|
|
4
|
+
const consts_1 = require("../../consts");
|
|
5
|
+
const AxiosGQL_1 = require("./AxiosGQL");
|
|
6
|
+
class EASClient extends AxiosGQL_1.AxiosGQL {
|
|
7
|
+
constructor(args) {
|
|
8
|
+
const { network } = args;
|
|
9
|
+
super(consts_1.Networks[network].url);
|
|
10
|
+
this.assert(args);
|
|
11
|
+
this._network = { ...consts_1.Networks[network], name: network };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validate the constructor arguments
|
|
15
|
+
* @param args
|
|
16
|
+
*/
|
|
17
|
+
assert(args) {
|
|
18
|
+
if (!consts_1.Networks[args.network]) {
|
|
19
|
+
throw new Error("Invalid network");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
get network() {
|
|
23
|
+
return this._network.name;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.EASClient = EASClient;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Attestation } from "../Attestation";
|
|
2
|
+
import { EASNetworkConfig, Hex, IAttestation, TNetwork, TSchemaName } from "../../types";
|
|
3
|
+
import { Grantee } from "../types/attestations";
|
|
4
|
+
import { GapSchema } from "../GapSchema";
|
|
5
|
+
import { Grant, Milestone, Project, MemberOf } from "../entities";
|
|
6
|
+
import { Community } from "../entities/Community";
|
|
7
|
+
import { Fetcher } from "../Fetcher";
|
|
8
|
+
interface EASClientProps {
|
|
9
|
+
network: TNetwork;
|
|
10
|
+
}
|
|
11
|
+
export declare class GapEasClient extends Fetcher {
|
|
12
|
+
network: EASNetworkConfig & {
|
|
13
|
+
name: TNetwork;
|
|
14
|
+
};
|
|
15
|
+
constructor(args: EASClientProps);
|
|
16
|
+
/**
|
|
17
|
+
* Fetches all the schemas deployed by an owner
|
|
18
|
+
* @param owner
|
|
19
|
+
*/
|
|
20
|
+
schemas(owner: Hex): Promise<GapSchema[]>;
|
|
21
|
+
attestation<T = unknown>(uid: Hex): Promise<Attestation<T, GapSchema>>;
|
|
22
|
+
attestations(schemaName: TSchemaName, search?: string): Promise<IAttestation[]>;
|
|
23
|
+
attestationsOf(schemaName: TSchemaName, recipient: Hex): Promise<IAttestation[]>;
|
|
24
|
+
attestationsTo(schemaName: TSchemaName, recipient: Hex): Promise<IAttestation[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Fetch all dependent attestations of a parent schema.
|
|
27
|
+
* @param parentSchema the schema name to get dependents of.
|
|
28
|
+
* @param parentUid the parent uid to get dependents of.
|
|
29
|
+
*/
|
|
30
|
+
dependentsOf(parentSchema: TSchemaName, parentUid: Hex): Promise<Attestation[]>;
|
|
31
|
+
communities(search?: string): Promise<Community[]>;
|
|
32
|
+
communitiesOf(address?: Hex): Promise<Community[]>;
|
|
33
|
+
communitiesAdminOf(address?: Hex): Promise<Community[]>;
|
|
34
|
+
communitiesByIds(uids: Hex[]): Promise<Community[]>;
|
|
35
|
+
communitiesDetails(communities: Community[]): Promise<Community[]>;
|
|
36
|
+
communityBySlug(slug: string): Promise<Community>;
|
|
37
|
+
communityById(uid: Hex): Promise<Community>;
|
|
38
|
+
/**
|
|
39
|
+
* Fetch the details for a set of
|
|
40
|
+
* projects with project grants,
|
|
41
|
+
* members, milestones, and tags.
|
|
42
|
+
* @param projects
|
|
43
|
+
*/
|
|
44
|
+
projectsDetails(projects: Project[]): Promise<Project[]>;
|
|
45
|
+
projectById(uid: Hex): Promise<Project>;
|
|
46
|
+
projectBySlug(slug: string): Promise<Project>;
|
|
47
|
+
slugExists(slug: string): Promise<boolean>;
|
|
48
|
+
search(query: string): Promise<{
|
|
49
|
+
projects: Project[];
|
|
50
|
+
communities: Community[];
|
|
51
|
+
}>;
|
|
52
|
+
searchProjects(query: string): Promise<Project[]>;
|
|
53
|
+
projects(name?: string): Promise<Project[]>;
|
|
54
|
+
projectsOf(grantee: Hex): Promise<Project[]>;
|
|
55
|
+
grantee(address: Hex): Promise<Grantee>;
|
|
56
|
+
grantees(): Promise<Grantee[]>;
|
|
57
|
+
grantsOf(grantee: Hex, withCommunity?: boolean): Promise<Grant[]>;
|
|
58
|
+
grantsUpdates(grants: Grant[]): Promise<Grant[]>;
|
|
59
|
+
grantsByCommunity(uid: Hex): Promise<Grant[]>;
|
|
60
|
+
grantsFor(projects: Project[], withCommunity?: boolean): Promise<Grant[]>;
|
|
61
|
+
milestonesOf(grants: Grant[]): Promise<Milestone[]>;
|
|
62
|
+
membersOf(projects: Project[]): Promise<MemberOf[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns a string to be used to search by a value in `decodedDataJson`.
|
|
65
|
+
* @param field
|
|
66
|
+
* @param value
|
|
67
|
+
*/
|
|
68
|
+
private getSearchFieldString;
|
|
69
|
+
grantsForExtProject(projectExtId: string): Promise<Grant[]>;
|
|
70
|
+
}
|
|
71
|
+
export {};
|