@show-karma/karma-gap-sdk 0.3.32 → 0.3.34
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/class/GrantProgramRegistry/Allo.d.ts +5 -4
- package/core/class/GrantProgramRegistry/Allo.js +21 -15
- package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +5 -4
- package/core/class/GrantProgramRegistry/AlloRegistry.js +14 -8
- package/core/class/entities/MemberOf.d.ts +1 -1
- package/core/class/karma-indexer/api/types.d.ts +4 -0
- package/core/class/remote-storage/IpfsStorage.d.ts +8 -7
- package/core/class/remote-storage/IpfsStorage.js +24 -7
- package/core/class/types/attestations.d.ts +8 -0
- package/core/consts.js +4 -4
- package/core/utils/gelato/send-gelato-txn.js +1 -1
- package/package.json +1 -2
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import { NFTStorage } from "nft.storage";
|
|
3
2
|
export declare class AlloBase {
|
|
4
3
|
private signer;
|
|
5
4
|
private contract;
|
|
6
|
-
private static ipfsClient;
|
|
7
5
|
private allo;
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
private pinataJWTToken;
|
|
7
|
+
constructor(signer: ethers.Signer, pinataJWTToken: string, chainId: number);
|
|
8
|
+
saveAndGetCID(data: any, pinataMetadata?: {
|
|
9
|
+
name: string;
|
|
10
|
+
}): Promise<any>;
|
|
10
11
|
encodeStrategyInitData(applicationStart: number, applicationEnd: number, roundStart: number, roundEnd: number, payoutToken: string): Promise<string>;
|
|
11
12
|
createGrant(args: any): Promise<{
|
|
12
13
|
poolId: string;
|
|
@@ -9,34 +9,40 @@ const Allo_json_1 = __importDefault(require("../../abi/Allo.json"));
|
|
|
9
9
|
const consts_1 = require("../../consts");
|
|
10
10
|
const ethers_2 = require("ethers");
|
|
11
11
|
const allo_v2_sdk_1 = require("@allo-team/allo-v2-sdk/");
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
13
|
class AlloBase {
|
|
13
|
-
constructor(signer,
|
|
14
|
+
constructor(signer, pinataJWTToken, chainId) {
|
|
14
15
|
this.signer = signer;
|
|
15
16
|
this.contract = new ethers_1.ethers.Contract(consts_1.AlloContracts.alloProxy, Allo_json_1.default, signer);
|
|
16
17
|
this.allo = new allo_v2_sdk_1.Allo({ chain: chainId });
|
|
17
|
-
|
|
18
|
+
this.pinataJWTToken = pinataJWTToken;
|
|
18
19
|
}
|
|
19
|
-
async saveAndGetCID(data) {
|
|
20
|
+
async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
|
|
20
21
|
try {
|
|
21
|
-
const
|
|
22
|
-
|
|
22
|
+
const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
|
|
23
|
+
pinataContent: data,
|
|
24
|
+
pinataMetadata: pinataMetadata,
|
|
25
|
+
}, {
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
Authorization: `Bearer ${this.pinataJWTToken}`,
|
|
29
|
+
},
|
|
23
30
|
});
|
|
24
|
-
|
|
25
|
-
return cid;
|
|
31
|
+
return res.data.IpfsHash;
|
|
26
32
|
}
|
|
27
33
|
catch (error) {
|
|
28
|
-
|
|
34
|
+
console.log(error);
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
async encodeStrategyInitData(applicationStart, applicationEnd, roundStart, roundEnd, payoutToken) {
|
|
32
38
|
const encoder = new ethers_2.AbiCoder();
|
|
33
39
|
const initStrategyData = encoder.encode(["bool", "bool", "uint256", "uint256", "uint256", "uint256", "address[]"], [
|
|
34
|
-
false,
|
|
35
|
-
true,
|
|
36
|
-
applicationStart,
|
|
37
|
-
applicationEnd,
|
|
38
|
-
roundStart,
|
|
39
|
-
roundEnd,
|
|
40
|
+
false,
|
|
41
|
+
true,
|
|
42
|
+
applicationStart,
|
|
43
|
+
applicationEnd,
|
|
44
|
+
roundStart,
|
|
45
|
+
roundEnd,
|
|
40
46
|
[payoutToken],
|
|
41
47
|
]);
|
|
42
48
|
return initStrategyData;
|
|
@@ -58,7 +64,7 @@ class AlloBase {
|
|
|
58
64
|
const createPoolArgs = {
|
|
59
65
|
profileId: args.profileId,
|
|
60
66
|
strategy: args.strategy,
|
|
61
|
-
initStrategyData: initStrategyData,
|
|
67
|
+
initStrategyData: initStrategyData,
|
|
62
68
|
token: args.payoutToken,
|
|
63
69
|
amount: BigInt(args.matchingFundAmt),
|
|
64
70
|
metadata: metadata,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import { ProfileMetadata } from "../types/allo";
|
|
3
|
-
import { NFTStorage } from "nft.storage";
|
|
4
3
|
export declare class AlloRegistry {
|
|
5
4
|
private contract;
|
|
6
|
-
private
|
|
7
|
-
constructor(signer: ethers.Signer,
|
|
8
|
-
saveAndGetCID(data: any
|
|
5
|
+
private pinataJWTToken;
|
|
6
|
+
constructor(signer: ethers.Signer, pinataJWTToken: string);
|
|
7
|
+
saveAndGetCID(data: any, pinataMetadata?: {
|
|
8
|
+
name: string;
|
|
9
|
+
}): Promise<any>;
|
|
9
10
|
createProgram(nonce: number, name: string, profileMetadata: ProfileMetadata, owner: string, members: string[]): Promise<{
|
|
10
11
|
profileId: any;
|
|
11
12
|
txHash: any;
|
|
@@ -7,21 +7,27 @@ exports.AlloRegistry = void 0;
|
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const AlloRegistry_json_1 = __importDefault(require("../../abi/AlloRegistry.json"));
|
|
9
9
|
const consts_1 = require("../../consts");
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
11
|
class AlloRegistry {
|
|
11
|
-
constructor(signer,
|
|
12
|
+
constructor(signer, pinataJWTToken) {
|
|
12
13
|
this.contract = new ethers_1.ethers.Contract(consts_1.AlloContracts.registry, AlloRegistry_json_1.default, signer);
|
|
13
|
-
|
|
14
|
+
this.pinataJWTToken = pinataJWTToken;
|
|
14
15
|
}
|
|
15
|
-
async saveAndGetCID(data) {
|
|
16
|
+
async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
|
|
16
17
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
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
|
+
},
|
|
19
26
|
});
|
|
20
|
-
|
|
21
|
-
return cid;
|
|
27
|
+
return res.data.IpfsHash;
|
|
22
28
|
}
|
|
23
29
|
catch (error) {
|
|
24
|
-
|
|
30
|
+
console.log(error);
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
async createProgram(nonce, name, profileMetadata, owner, members) {
|
|
@@ -6,6 +6,6 @@ export interface IMemberOf {
|
|
|
6
6
|
}
|
|
7
7
|
export declare class MemberOf extends Attestation<IMemberOf> {
|
|
8
8
|
details?: MemberDetails;
|
|
9
|
-
multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("
|
|
9
|
+
multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("..").GapSchema>, import("core/types").RawMultiAttestPayload][]>;
|
|
10
10
|
attest(signer: SignerOrProvider, callback?: Function): Promise<void>;
|
|
11
11
|
}
|
|
@@ -108,6 +108,10 @@ export interface IProjectDetails extends IAttestationResponse {
|
|
|
108
108
|
tags?: ITag[];
|
|
109
109
|
slug?: string;
|
|
110
110
|
type: "project-details";
|
|
111
|
+
businessModel?: string;
|
|
112
|
+
stageIn?: string;
|
|
113
|
+
raisedMoney?: string;
|
|
114
|
+
pathToTake?: string;
|
|
111
115
|
};
|
|
112
116
|
}
|
|
113
117
|
export interface IProjectImpact extends IAttestationResponse {
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { RemoteStorage } from './RemoteStorage';
|
|
4
|
-
import { TRemoteStorageOutput } from 'core/types';
|
|
1
|
+
import { RemoteStorage } from "./RemoteStorage";
|
|
2
|
+
import { TRemoteStorageOutput } from "core/types";
|
|
5
3
|
export interface IpfsStorageOptions {
|
|
6
4
|
token: string;
|
|
7
|
-
endpoint?: URL;
|
|
8
5
|
}
|
|
9
|
-
export declare class IpfsStorage extends RemoteStorage
|
|
6
|
+
export declare class IpfsStorage extends RemoteStorage {
|
|
7
|
+
private pinataJWTToken;
|
|
10
8
|
constructor(opts: IpfsStorageOptions,
|
|
11
9
|
/**
|
|
12
10
|
* If set, will send request to another server instead of
|
|
13
11
|
* using the local instance
|
|
14
12
|
*/
|
|
15
|
-
sponsor?: RemoteStorage[
|
|
13
|
+
sponsor?: RemoteStorage["sponsor"]);
|
|
16
14
|
private assert;
|
|
17
15
|
save<T = unknown>(data: T): Promise<string>;
|
|
18
16
|
encode(data: string): TRemoteStorageOutput<string>;
|
|
19
17
|
get<T = unknown>(args: {
|
|
20
18
|
cid: string;
|
|
21
19
|
}): Promise<T>;
|
|
20
|
+
saveAndGetCID(data: any, pinataMetadata?: {
|
|
21
|
+
name: string;
|
|
22
|
+
}): Promise<any>;
|
|
22
23
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.IpfsStorage = void 0;
|
|
4
|
-
const nft_storage_1 = require("nft.storage");
|
|
5
7
|
const RemoteStorage_1 = require("./RemoteStorage");
|
|
6
8
|
const SchemaError_1 = require("../SchemaError");
|
|
7
9
|
const utils_1 = require("../../utils");
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
11
|
class IpfsStorage extends RemoteStorage_1.RemoteStorage {
|
|
9
12
|
constructor(opts,
|
|
10
13
|
/**
|
|
@@ -14,19 +17,16 @@ class IpfsStorage extends RemoteStorage_1.RemoteStorage {
|
|
|
14
17
|
sponsor) {
|
|
15
18
|
super(0 /* STORAGE_TYPE.IPFS */, sponsor);
|
|
16
19
|
this.assert(opts);
|
|
17
|
-
this.
|
|
20
|
+
this.pinataJWTToken = opts.token;
|
|
18
21
|
}
|
|
19
22
|
assert(opts) { }
|
|
20
23
|
async save(data) {
|
|
21
24
|
try {
|
|
22
|
-
const
|
|
23
|
-
type: 'application/json',
|
|
24
|
-
});
|
|
25
|
-
const cid = await this.client.storeBlob(blob);
|
|
25
|
+
const cid = await this.saveAndGetCID(data);
|
|
26
26
|
return cid;
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
throw new SchemaError_1.RemoteStorageError(
|
|
29
|
+
throw new SchemaError_1.RemoteStorageError("REMOTE_STORAGE_UPLOAD", `Error adding data to IPFS`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
encode(data) {
|
|
@@ -35,5 +35,22 @@ class IpfsStorage extends RemoteStorage_1.RemoteStorage {
|
|
|
35
35
|
async get(args) {
|
|
36
36
|
return (0, utils_1.getIPFSData)(args.cid);
|
|
37
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
|
+
console.log(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
38
55
|
}
|
|
39
56
|
exports.IpfsStorage = IpfsStorage;
|
|
@@ -95,6 +95,10 @@ export interface IProjectDetails {
|
|
|
95
95
|
externalIds?: string[];
|
|
96
96
|
slug?: string;
|
|
97
97
|
type?: string;
|
|
98
|
+
businessModel?: string;
|
|
99
|
+
stageIn?: string;
|
|
100
|
+
raisedMoney?: string;
|
|
101
|
+
pathToTake?: string;
|
|
98
102
|
}
|
|
99
103
|
export declare class ProjectDetails extends Attestation<IProjectDetails> implements IProjectDetails {
|
|
100
104
|
title: string;
|
|
@@ -105,6 +109,10 @@ export declare class ProjectDetails extends Attestation<IProjectDetails> impleme
|
|
|
105
109
|
slug: string;
|
|
106
110
|
type: string;
|
|
107
111
|
externalIds: string[];
|
|
112
|
+
businessModel?: string;
|
|
113
|
+
stageIn?: string;
|
|
114
|
+
raisedMoney?: string;
|
|
115
|
+
pathToTake?: string;
|
|
108
116
|
}
|
|
109
117
|
export declare class Grantee {
|
|
110
118
|
address: string;
|
package/core/consts.js
CHANGED
|
@@ -36,7 +36,7 @@ exports.Networks = {
|
|
|
36
36
|
contracts: {
|
|
37
37
|
eas: "0x4200000000000000000000000000000000000021",
|
|
38
38
|
schema: "0x4200000000000000000000000000000000000020",
|
|
39
|
-
multicall: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c",
|
|
39
|
+
multicall: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c",
|
|
40
40
|
projectResolver: "0x7177AdC0f924b695C0294A40C4C5FEFf5EE1E141",
|
|
41
41
|
communityResolver: "0x6dC1D6b864e8BEf815806f9e4677123496e12026",
|
|
42
42
|
donations: "0x021896771412C1D3f31BC7B01fFA3a6A17c5dA30",
|
|
@@ -84,7 +84,7 @@ exports.Networks = {
|
|
|
84
84
|
contracts: {
|
|
85
85
|
eas: "0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458",
|
|
86
86
|
schema: "0xA310da9c5B885E7fb3fbA9D66E9Ba6Df512b78eB",
|
|
87
|
-
multicall: "0x6dC1D6b864e8BEf815806f9e4677123496e12026",
|
|
87
|
+
multicall: "0x6dC1D6b864e8BEf815806f9e4677123496e12026",
|
|
88
88
|
projectResolver: "0x28BE0b0515be8BB8822aF1467A6613795E74717b",
|
|
89
89
|
communityResolver: "0xD534C4704F82494aBbc901560046fB62Ac63E9C4",
|
|
90
90
|
donations: "0x475F3E915601d975c792E6116791FBe9ACdBE902",
|
|
@@ -114,10 +114,10 @@ exports.Networks = {
|
|
|
114
114
|
donations: "0xb2021F7550b8B07cA71696159B592C1F713593e4",
|
|
115
115
|
},
|
|
116
116
|
schemas: {
|
|
117
|
-
Community: "0xf3d790c7fdab6c1b1f25ffcc9289e5be2792eb596d2851a4d059c8aae1bc8b2e",
|
|
117
|
+
Community: "0xf3d790c7fdab6c1b1f25ffcc9289e5be2792eb596d2851a4d059c8aae1bc8b2e",
|
|
118
118
|
// "0x1954572e3fe21bf4334afdaf1358ed7098af1ed136e76dc93c2fdc25e83934c1", // original without resolver
|
|
119
119
|
Details: "0x2c270e35bfcdc4d611f0e9d3d2ab6924ec6c673505abc22a1dd07e19b67211af",
|
|
120
|
-
Grant: "0x09697aeeb3ae71de1cc19e388fd74264f11af5fba3016094764553ac341fdc72",
|
|
120
|
+
Grant: "0x09697aeeb3ae71de1cc19e388fd74264f11af5fba3016094764553ac341fdc72",
|
|
121
121
|
GrantVerified: "0x0be8952e2dd74ffd63a02f4d55b20b603fe7a60130cb9d70de31feb9c52fdd37",
|
|
122
122
|
MemberOf: "0xdd87b3500457931252424f4439365534ba72a367503a8805ff3482353fb90301",
|
|
123
123
|
MilestoneApproved: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.34",
|
|
7
7
|
"description": "Simple and easy interface between EAS and Karma GAP.",
|
|
8
8
|
"main": "./index.js",
|
|
9
9
|
"author": "KarmaHQ",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@types/sha256": "^0.2.0",
|
|
26
26
|
"axios": "^1.4.0",
|
|
27
27
|
"ethers": "6.11.0",
|
|
28
|
-
"nft.storage": "^7.1.1",
|
|
29
28
|
"sha256": "^0.2.0",
|
|
30
29
|
"simple-ts-job-runner": "^1.0.12"
|
|
31
30
|
},
|