@show-karma/karma-gap-sdk 0.3.43 → 0.3.45
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 +622 -0
- package/core/abi/Donations.json +260 -0
- package/core/abi/EAS.json +1 -0
- package/core/abi/SchemaRegistry.json +1 -0
- package/core/abi/index.d.ts +1114 -0
- package/core/abi/index.js +26 -0
- package/core/class/Attestation.d.ts +3 -2
- package/core/class/Attestation.js +11 -8
- package/core/class/GAP.d.ts +1 -1
- package/core/class/GAP.js +9 -10
- package/core/class/GapSchema.js +1 -0
- package/core/class/GraphQL/GapEasClient.d.ts +7 -7
- package/core/class/GraphQL/GapEasClient.js +60 -60
- package/core/class/Schema.d.ts +12 -3
- package/core/class/Schema.js +32 -12
- package/core/class/SchemaError.d.ts +2 -1
- package/core/class/SchemaError.js +4 -3
- package/core/class/contract/GapContract.d.ts +11 -6
- package/core/class/contract/GapContract.js +35 -6
- package/core/class/entities/Community.d.ts +2 -2
- package/core/class/entities/Community.js +9 -3
- package/core/class/entities/Grant.d.ts +11 -11
- package/core/class/entities/Grant.js +33 -29
- package/core/class/entities/GrantUpdate.d.ts +8 -2
- package/core/class/entities/GrantUpdate.js +26 -6
- package/core/class/entities/MemberOf.d.ts +2 -2
- package/core/class/entities/MemberOf.js +4 -2
- package/core/class/entities/Milestone.d.ts +14 -7
- package/core/class/entities/Milestone.js +63 -21
- package/core/class/entities/Project.d.ts +10 -5
- package/core/class/entities/Project.js +77 -9
- package/core/class/entities/ProjectImpact.d.ts +7 -3
- package/core/class/entities/ProjectImpact.js +23 -6
- package/core/class/entities/ProjectMilestone.d.ts +60 -0
- package/core/class/entities/ProjectMilestone.js +174 -0
- package/core/class/entities/ProjectUpdate.d.ts +4 -2
- package/core/class/entities/ProjectUpdate.js +21 -5
- package/core/class/karma-indexer/GapIndexerClient.d.ts +9 -7
- package/core/class/karma-indexer/GapIndexerClient.js +15 -10
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +3 -1
- package/core/class/karma-indexer/api/GapIndexerApi.js +9 -0
- package/core/class/karma-indexer/api/types.d.ts +21 -0
- package/core/class/types/attestations.d.ts +20 -1
- package/core/class/types/attestations.js +4 -1
- package/core/consts.js +219 -45
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/types.d.ts +12 -2
- package/package.json +1 -1
- package/core/abi/AlloCaller.json +0 -117
|
@@ -19,7 +19,8 @@ declare const SchemaErrorCodes: {
|
|
|
19
19
|
export declare class SchemaError extends Error {
|
|
20
20
|
readonly code: number;
|
|
21
21
|
private readonly _message;
|
|
22
|
-
|
|
22
|
+
readonly originalError: any;
|
|
23
|
+
constructor(code: keyof typeof SchemaErrorCodes, append?: string, originalError?: any);
|
|
23
24
|
get message(): string;
|
|
24
25
|
}
|
|
25
26
|
export declare class AttestationError extends SchemaError {
|
|
@@ -20,10 +20,11 @@ const SchemaErrorCodes = {
|
|
|
20
20
|
REMOTE_STORAGE_UPLOAD: 50016,
|
|
21
21
|
};
|
|
22
22
|
class SchemaError extends Error {
|
|
23
|
-
constructor(code, append) {
|
|
24
|
-
super(`${code}${append ? `: ${append}` :
|
|
25
|
-
this._message = append || code.replace(/_/g,
|
|
23
|
+
constructor(code, append, originalError) {
|
|
24
|
+
super(`${code}${append ? `: ${append}` : ""}`);
|
|
25
|
+
this._message = append || code.replace(/_/g, " ");
|
|
26
26
|
this.code = SchemaErrorCodes[code];
|
|
27
|
+
this.originalError = originalError;
|
|
27
28
|
}
|
|
28
29
|
get message() {
|
|
29
30
|
return this._message;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CallbackStatus, Hex, RawAttestationPayload, RawMultiAttestPayload, SignerOrProvider } from "core/types";
|
|
2
2
|
import { MultiRevocationRequest } from "@ethereum-attestation-service/eas-sdk";
|
|
3
|
+
import { AttestationWithTx } from "../types/attestations";
|
|
4
|
+
import { Transaction } from "ethers";
|
|
3
5
|
export declare class GapContract {
|
|
4
6
|
static nonces: {
|
|
5
7
|
[key: string]: number;
|
|
@@ -30,27 +32,30 @@ export declare class GapContract {
|
|
|
30
32
|
* @param payload
|
|
31
33
|
* @returns
|
|
32
34
|
*/
|
|
33
|
-
static attest(signer: SignerOrProvider, payload: RawAttestationPayload, callback?: ((status: CallbackStatus) => void) & ((status: string) => void)): Promise
|
|
34
|
-
static attestBySig(signer: SignerOrProvider, payload: RawAttestationPayload): Promise
|
|
35
|
+
static attest(signer: SignerOrProvider, payload: RawAttestationPayload, callback?: ((status: CallbackStatus) => void) & ((status: string) => void)): Promise<AttestationWithTx>;
|
|
36
|
+
static attestBySig(signer: SignerOrProvider, payload: RawAttestationPayload): Promise<{
|
|
37
|
+
tx: Transaction[];
|
|
38
|
+
uids: `0x${string}`[];
|
|
39
|
+
}>;
|
|
35
40
|
/**
|
|
36
41
|
* Performs a referenced multi attestation.
|
|
37
42
|
*
|
|
38
43
|
* @returns an array with the attestation UIDs.
|
|
39
44
|
*/
|
|
40
|
-
static multiAttest(signer: SignerOrProvider, payload: RawMultiAttestPayload[], callback?: Function): Promise<
|
|
45
|
+
static multiAttest(signer: SignerOrProvider, payload: RawMultiAttestPayload[], callback?: Function): Promise<AttestationWithTx>;
|
|
41
46
|
/**
|
|
42
47
|
* Performs a referenced multi attestation.
|
|
43
48
|
*
|
|
44
49
|
* @returns an array with the attestation UIDs.
|
|
45
50
|
*/
|
|
46
|
-
static multiAttestBySig(signer: SignerOrProvider, payload: RawMultiAttestPayload[]): Promise<
|
|
47
|
-
static multiRevoke(signer: SignerOrProvider, payload: MultiRevocationRequest[]): Promise<
|
|
51
|
+
static multiAttestBySig(signer: SignerOrProvider, payload: RawMultiAttestPayload[]): Promise<AttestationWithTx>;
|
|
52
|
+
static multiRevoke(signer: SignerOrProvider, payload: MultiRevocationRequest[]): Promise<AttestationWithTx>;
|
|
48
53
|
/**
|
|
49
54
|
* Performs a referenced multi attestation.
|
|
50
55
|
*
|
|
51
56
|
* @returns an array with the attestation UIDs.
|
|
52
57
|
*/
|
|
53
|
-
static multiRevokeBySig(signer: SignerOrProvider, payload: MultiRevocationRequest[]): Promise<
|
|
58
|
+
static multiRevokeBySig(signer: SignerOrProvider, payload: MultiRevocationRequest[]): Promise<AttestationWithTx>;
|
|
54
59
|
/**
|
|
55
60
|
* Transfer the ownership of an attestation
|
|
56
61
|
* @param signer
|
|
@@ -90,7 +90,11 @@ class GapContract {
|
|
|
90
90
|
const result = await tx.wait?.();
|
|
91
91
|
callback?.("confirmed");
|
|
92
92
|
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result)[0];
|
|
93
|
-
|
|
93
|
+
const resultArray = [result].flat();
|
|
94
|
+
return {
|
|
95
|
+
tx: resultArray,
|
|
96
|
+
uids: [attestations],
|
|
97
|
+
};
|
|
94
98
|
}
|
|
95
99
|
static async attestBySig(signer, payload) {
|
|
96
100
|
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
@@ -110,7 +114,14 @@ class GapContract {
|
|
|
110
114
|
let contractAddress = await contract.getAddress();
|
|
111
115
|
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
112
116
|
const attestations = await this.getTransactionLogs(signer, txn);
|
|
113
|
-
return
|
|
117
|
+
return {
|
|
118
|
+
tx: [
|
|
119
|
+
{
|
|
120
|
+
hash: txn,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
uids: attestations,
|
|
124
|
+
};
|
|
114
125
|
}
|
|
115
126
|
/**
|
|
116
127
|
* Performs a referenced multi attestation.
|
|
@@ -131,7 +142,11 @@ class GapContract {
|
|
|
131
142
|
if (callback)
|
|
132
143
|
callback("confirmed");
|
|
133
144
|
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result);
|
|
134
|
-
|
|
145
|
+
const resultArray = [result].flat();
|
|
146
|
+
return {
|
|
147
|
+
tx: resultArray,
|
|
148
|
+
uids: attestations,
|
|
149
|
+
};
|
|
135
150
|
}
|
|
136
151
|
/**
|
|
137
152
|
* Performs a referenced multi attestation.
|
|
@@ -151,7 +166,14 @@ class GapContract {
|
|
|
151
166
|
let contractAddress = await contract.getAddress();
|
|
152
167
|
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
153
168
|
const attestations = await this.getTransactionLogs(signer, txn);
|
|
154
|
-
return
|
|
169
|
+
return {
|
|
170
|
+
tx: [
|
|
171
|
+
{
|
|
172
|
+
hash: txn,
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
uids: attestations,
|
|
176
|
+
};
|
|
155
177
|
}
|
|
156
178
|
static async multiRevoke(signer, payload) {
|
|
157
179
|
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
@@ -159,7 +181,10 @@ class GapContract {
|
|
|
159
181
|
return this.multiRevokeBySig(signer, payload);
|
|
160
182
|
}
|
|
161
183
|
const tx = await contract.multiRevoke(payload);
|
|
162
|
-
return
|
|
184
|
+
return {
|
|
185
|
+
tx: [tx],
|
|
186
|
+
uids: [],
|
|
187
|
+
};
|
|
163
188
|
}
|
|
164
189
|
/**
|
|
165
190
|
* Performs a referenced multi attestation.
|
|
@@ -177,7 +202,11 @@ class GapContract {
|
|
|
177
202
|
if (!populatedTxn)
|
|
178
203
|
throw new Error("Transaction data is empty");
|
|
179
204
|
let contractAddress = await contract.getAddress();
|
|
180
|
-
await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
205
|
+
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
206
|
+
return {
|
|
207
|
+
tx: [{ hash: txn }],
|
|
208
|
+
uids: [],
|
|
209
|
+
};
|
|
181
210
|
}
|
|
182
211
|
/**
|
|
183
212
|
* Transfer the ownership of an attestation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Attestation } from "../Attestation";
|
|
2
|
-
import { CommunityDetails, ICommunityDetails } from "../types/attestations";
|
|
2
|
+
import { AttestationWithTx, CommunityDetails, ICommunityDetails } from "../types/attestations";
|
|
3
3
|
import { Project } from "./Project";
|
|
4
4
|
import { MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
|
|
5
5
|
import { Grant } from "./Grant";
|
|
@@ -29,6 +29,6 @@ export declare class Community extends Attestation<ICommunity> {
|
|
|
29
29
|
* @param signer
|
|
30
30
|
* @param details
|
|
31
31
|
*/
|
|
32
|
-
attest(signer: SignerOrProvider, details?: ICommunityDetails, callback?: Function): Promise<
|
|
32
|
+
attest(signer: SignerOrProvider, details?: ICommunityDetails, callback?: Function): Promise<AttestationWithTx>;
|
|
33
33
|
static from(attestations: ICommunityResponse[], network: TNetwork): Community[];
|
|
34
34
|
}
|
|
@@ -45,12 +45,13 @@ class Community extends Attestation_1.Attestation {
|
|
|
45
45
|
try {
|
|
46
46
|
if (callback)
|
|
47
47
|
callback("preparing");
|
|
48
|
-
|
|
48
|
+
const { tx: communityTx, uids: communityUID } = await this.schema.attest({
|
|
49
49
|
signer,
|
|
50
50
|
to: this.recipient,
|
|
51
51
|
refUID: consts_1.nullRef,
|
|
52
52
|
data: this.data,
|
|
53
53
|
});
|
|
54
|
+
this._uid = communityTx[0].hash;
|
|
54
55
|
console.log(this.uid);
|
|
55
56
|
if (callback)
|
|
56
57
|
callback("pending");
|
|
@@ -61,14 +62,19 @@ class Community extends Attestation_1.Attestation {
|
|
|
61
62
|
refUID: this.uid,
|
|
62
63
|
schema: this.schema.gap.findSchema("CommunityDetails"),
|
|
63
64
|
});
|
|
64
|
-
await communityDetails.attest(signer);
|
|
65
|
+
const { tx: communityDetailsTx, uids: communityDetailsUID } = await communityDetails.attest(signer);
|
|
66
|
+
return {
|
|
67
|
+
tx: [communityTx[0], communityDetailsTx[0]],
|
|
68
|
+
uids: [communityUID[0], communityDetailsUID[0]],
|
|
69
|
+
};
|
|
65
70
|
}
|
|
66
71
|
if (callback)
|
|
67
72
|
callback("confirmed");
|
|
73
|
+
return { tx: communityTx, uids: communityUID };
|
|
68
74
|
}
|
|
69
75
|
catch (error) {
|
|
70
76
|
console.error(error);
|
|
71
|
-
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.");
|
|
77
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.", error);
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
static from(attestations, network) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Attestation } from
|
|
2
|
-
import { GrantDetails, GrantRound, GrantCompleted } from
|
|
3
|
-
import { IMilestone, Milestone } from
|
|
4
|
-
import { GapSchema } from
|
|
5
|
-
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from
|
|
6
|
-
import { Community } from
|
|
7
|
-
import { IGrantResponse } from
|
|
8
|
-
import { GrantUpdate, IGrantUpdate } from
|
|
1
|
+
import { Attestation } from "../Attestation";
|
|
2
|
+
import { GrantDetails, GrantRound, GrantCompleted, AttestationWithTx } from "../types/attestations";
|
|
3
|
+
import { IMilestone, Milestone } from "./Milestone";
|
|
4
|
+
import { GapSchema } from "../GapSchema";
|
|
5
|
+
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
|
|
6
|
+
import { Community } from "./Community";
|
|
7
|
+
import { IGrantResponse } from "../karma-indexer/api/types";
|
|
8
|
+
import { GrantUpdate, IGrantUpdate } from "./GrantUpdate";
|
|
9
9
|
export interface IGrant {
|
|
10
10
|
communityUID: Hex;
|
|
11
11
|
}
|
|
@@ -44,16 +44,16 @@ export declare class Grant extends Attestation<IGrant> {
|
|
|
44
44
|
* @param projectIdx
|
|
45
45
|
*/
|
|
46
46
|
multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, GapSchema>, import("core/types").RawMultiAttestPayload][]>;
|
|
47
|
-
attestProject(signer: SignerOrProvider, originalProjectChainId: number): Promise<
|
|
47
|
+
attestProject(signer: SignerOrProvider, originalProjectChainId: number): Promise<AttestationWithTx>;
|
|
48
48
|
/**
|
|
49
49
|
* @inheritdoc
|
|
50
50
|
*/
|
|
51
|
-
attest(signer: SignerOrProvider, projectChainId: number, callback?: Function): Promise<
|
|
51
|
+
attest(signer: SignerOrProvider, projectChainId: number, callback?: Function): Promise<AttestationWithTx>;
|
|
52
52
|
attestUpdate(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<void>;
|
|
53
|
-
complete(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<void>;
|
|
54
53
|
/**
|
|
55
54
|
* Validate if the grant has a valid reference to a community.
|
|
56
55
|
*/
|
|
57
56
|
protected assertPayload(): boolean;
|
|
57
|
+
complete(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<AttestationWithTx>;
|
|
58
58
|
static from(attestations: IGrantResponse[], network: TNetwork): Grant[];
|
|
59
59
|
}
|
|
@@ -22,8 +22,8 @@ class Grant extends Attestation_1.Attestation {
|
|
|
22
22
|
}
|
|
23
23
|
async verify(signer) {
|
|
24
24
|
const eas = this.schema.gap.eas.connect(signer);
|
|
25
|
-
const schema = this.schema.gap.findSchema(
|
|
26
|
-
schema.setValue(
|
|
25
|
+
const schema = this.schema.gap.findSchema("MilestoneApproved");
|
|
26
|
+
schema.setValue("approved", true);
|
|
27
27
|
try {
|
|
28
28
|
await eas.attest({
|
|
29
29
|
schema: schema.raw,
|
|
@@ -39,7 +39,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
41
|
console.error(error);
|
|
42
|
-
throw new SchemaError_1.AttestationError(
|
|
42
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -48,7 +48,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
48
48
|
* @param milestones
|
|
49
49
|
*/
|
|
50
50
|
addMilestones(milestones) {
|
|
51
|
-
const schema = this.schema.gap.findSchema(
|
|
51
|
+
const schema = this.schema.gap.findSchema("Milestone");
|
|
52
52
|
const newMilestones = milestones.map((milestone) => {
|
|
53
53
|
const m = new Milestone_1.Milestone({
|
|
54
54
|
data: milestone,
|
|
@@ -90,7 +90,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
90
90
|
async attestProject(signer, originalProjectChainId) {
|
|
91
91
|
const project = new Project_1.Project({
|
|
92
92
|
data: { project: true },
|
|
93
|
-
schema: this.schema.gap.findSchema(
|
|
93
|
+
schema: this.schema.gap.findSchema("Project"),
|
|
94
94
|
recipient: this.recipient,
|
|
95
95
|
chainID: this.chainID,
|
|
96
96
|
});
|
|
@@ -101,12 +101,13 @@ class Grant extends Attestation_1.Attestation {
|
|
|
101
101
|
},
|
|
102
102
|
chainID: this.chainID,
|
|
103
103
|
recipient: this.recipient,
|
|
104
|
-
schema: this.schema.gap.findSchema(
|
|
104
|
+
schema: this.schema.gap.findSchema("ProjectDetails"),
|
|
105
105
|
});
|
|
106
106
|
// Overwrite refuid
|
|
107
107
|
Object.assign(this, { refUID: consts_1.nullRef });
|
|
108
108
|
project.grants = [this];
|
|
109
|
-
await project.attest(signer);
|
|
109
|
+
const attestation = await project.attest(signer);
|
|
110
|
+
return attestation;
|
|
110
111
|
}
|
|
111
112
|
/**
|
|
112
113
|
* @inheritdoc
|
|
@@ -117,46 +118,49 @@ class Grant extends Attestation_1.Attestation {
|
|
|
117
118
|
}
|
|
118
119
|
this.assertPayload();
|
|
119
120
|
const payload = await this.multiAttestPayload();
|
|
120
|
-
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
const { tx, uids } = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
122
|
+
if (Array.isArray(uids)) {
|
|
123
|
+
uids.forEach((uid, index) => {
|
|
124
|
+
payload[index][0].uid = uid;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return { tx, uids };
|
|
125
128
|
}
|
|
126
129
|
async attestUpdate(signer, data, callback) {
|
|
127
130
|
const grantUpdate = new GrantUpdate_1.GrantUpdate({
|
|
128
131
|
data: {
|
|
129
132
|
...data,
|
|
130
|
-
type:
|
|
133
|
+
type: "grant-update",
|
|
131
134
|
},
|
|
132
135
|
recipient: this.recipient,
|
|
133
136
|
refUID: this.uid,
|
|
134
|
-
schema: this.schema.gap.findSchema(
|
|
137
|
+
schema: this.schema.gap.findSchema("GrantDetails"),
|
|
135
138
|
});
|
|
136
139
|
await grantUpdate.attest(signer, callback);
|
|
137
140
|
this.updates.push(grantUpdate);
|
|
138
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Validate if the grant has a valid reference to a community.
|
|
144
|
+
*/
|
|
145
|
+
assertPayload() {
|
|
146
|
+
if (!this.details || !this.communityUID) {
|
|
147
|
+
throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Grant should include a valid reference to a community on its details.");
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
139
151
|
async complete(signer, data, callback) {
|
|
140
152
|
const completed = new attestations_1.GrantCompleted({
|
|
141
153
|
data: {
|
|
142
154
|
...data,
|
|
143
|
-
type:
|
|
155
|
+
type: "grant-completed",
|
|
144
156
|
},
|
|
145
157
|
recipient: this.recipient,
|
|
146
158
|
refUID: this.uid,
|
|
147
|
-
schema: this.schema.gap.findSchema(
|
|
159
|
+
schema: this.schema.gap.findSchema("GrantDetails"),
|
|
148
160
|
});
|
|
149
|
-
await completed.attest(signer, callback);
|
|
161
|
+
const { tx, uids } = await completed.attest(signer, callback);
|
|
150
162
|
this.completed = completed;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Validate if the grant has a valid reference to a community.
|
|
154
|
-
*/
|
|
155
|
-
assertPayload() {
|
|
156
|
-
if (!this.details || !this.communityUID) {
|
|
157
|
-
throw new SchemaError_1.AttestationError('INVALID_REFERENCE', 'Grant should include a valid reference to a community on its details.');
|
|
158
|
-
}
|
|
159
|
-
return true;
|
|
163
|
+
return { tx, uids };
|
|
160
164
|
}
|
|
161
165
|
static from(attestations, network) {
|
|
162
166
|
return attestations.map((attestation) => {
|
|
@@ -165,7 +169,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
165
169
|
data: {
|
|
166
170
|
communityUID: attestation.data.communityUID,
|
|
167
171
|
},
|
|
168
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
172
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("Grant", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
169
173
|
chainID: attestation.chainID,
|
|
170
174
|
});
|
|
171
175
|
if (attestation.details) {
|
|
@@ -175,7 +179,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
175
179
|
data: {
|
|
176
180
|
...details.data,
|
|
177
181
|
},
|
|
178
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
182
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantDetails", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
179
183
|
chainID: attestation.chainID,
|
|
180
184
|
});
|
|
181
185
|
}
|
|
@@ -194,7 +198,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
194
198
|
data: {
|
|
195
199
|
...completed.data,
|
|
196
200
|
},
|
|
197
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
201
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantDetails", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
198
202
|
chainID: attestation.chainID,
|
|
199
203
|
});
|
|
200
204
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { SignerOrProvider, TNetwork } from "../../../core/types";
|
|
2
2
|
import { Attestation } from "../Attestation";
|
|
3
|
+
import { Transaction } from "ethers";
|
|
3
4
|
export interface _IGrantUpdate extends GrantUpdate {
|
|
4
5
|
}
|
|
5
6
|
export interface IGrantUpdate {
|
|
6
7
|
title: string;
|
|
7
8
|
text: string;
|
|
8
9
|
type?: string;
|
|
10
|
+
proofOfWork?: string;
|
|
9
11
|
}
|
|
10
12
|
type IStatus = "verified";
|
|
11
13
|
export interface IGrantUpdateStatus {
|
|
12
|
-
type
|
|
14
|
+
type?: `grant-update-${IStatus}`;
|
|
13
15
|
reason?: string;
|
|
14
16
|
}
|
|
15
17
|
export declare class GrantUpdateStatus extends Attestation<IGrantUpdateStatus> implements IGrantUpdateStatus {
|
|
@@ -19,6 +21,7 @@ export declare class GrantUpdateStatus extends Attestation<IGrantUpdateStatus> i
|
|
|
19
21
|
export declare class GrantUpdate extends Attestation<IGrantUpdate> implements IGrantUpdate {
|
|
20
22
|
title: string;
|
|
21
23
|
text: string;
|
|
24
|
+
proofOfWork: string;
|
|
22
25
|
verified: GrantUpdateStatus[];
|
|
23
26
|
/**
|
|
24
27
|
* Attest the status of the milestone as approved, rejected or completed.
|
|
@@ -30,7 +33,10 @@ export declare class GrantUpdate extends Attestation<IGrantUpdate> implements IG
|
|
|
30
33
|
* @param signer
|
|
31
34
|
* @param reason
|
|
32
35
|
*/
|
|
33
|
-
verify(signer: SignerOrProvider,
|
|
36
|
+
verify(signer: SignerOrProvider, data?: IGrantUpdateStatus, callback?: Function): Promise<{
|
|
37
|
+
tx: Transaction[];
|
|
38
|
+
uids: `0x${string}`[];
|
|
39
|
+
}>;
|
|
34
40
|
static from(attestations: _IGrantUpdate[], network: TNetwork): GrantUpdate[];
|
|
35
41
|
}
|
|
36
42
|
export {};
|
|
@@ -37,10 +37,18 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
37
37
|
if (callback)
|
|
38
38
|
callback("confirmed");
|
|
39
39
|
console.log(uid);
|
|
40
|
+
return {
|
|
41
|
+
tx: [
|
|
42
|
+
{
|
|
43
|
+
hash: tx.tx.hash,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
uids: [uid],
|
|
47
|
+
};
|
|
40
48
|
}
|
|
41
49
|
catch (error) {
|
|
42
50
|
console.error(error);
|
|
43
|
-
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
|
|
51
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
/**
|
|
@@ -49,23 +57,35 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
49
57
|
* @param signer
|
|
50
58
|
* @param reason
|
|
51
59
|
*/
|
|
52
|
-
async verify(signer,
|
|
60
|
+
async verify(signer, data, callback) {
|
|
53
61
|
console.log("Verifying");
|
|
54
62
|
const schema = this.schema.gap.findSchema("GrantUpdateStatus");
|
|
55
|
-
schema.
|
|
56
|
-
|
|
63
|
+
if (this.schema.isJsonSchema()) {
|
|
64
|
+
schema.setValue("json", JSON.stringify({
|
|
65
|
+
type: "grant-update-verified",
|
|
66
|
+
...data,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
schema.setValue("type", "grant-update-verified");
|
|
71
|
+
schema.setValue("reason", data?.reason || "");
|
|
72
|
+
}
|
|
57
73
|
console.log("Before attest grant update verified");
|
|
58
|
-
await this.attestStatus(signer, schema, callback);
|
|
74
|
+
const { tx, uids } = await this.attestStatus(signer, schema, callback);
|
|
59
75
|
console.log("After attest grant update verified");
|
|
60
76
|
this.verified.push(new GrantUpdateStatus({
|
|
61
77
|
data: {
|
|
62
78
|
type: "grant-update-verified",
|
|
63
|
-
|
|
79
|
+
...data,
|
|
64
80
|
},
|
|
65
81
|
refUID: this.uid,
|
|
66
82
|
schema: schema,
|
|
67
83
|
recipient: this.recipient,
|
|
68
84
|
}));
|
|
85
|
+
return {
|
|
86
|
+
tx,
|
|
87
|
+
uids,
|
|
88
|
+
};
|
|
69
89
|
}
|
|
70
90
|
static from(attestations, network) {
|
|
71
91
|
return attestations.map((attestation) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MultiAttestPayload, SignerOrProvider } from "core/types";
|
|
2
2
|
import { Attestation } from "../Attestation";
|
|
3
|
-
import { MemberDetails } from "../types/attestations";
|
|
3
|
+
import { AttestationWithTx, MemberDetails } from "../types/attestations";
|
|
4
4
|
export interface IMemberOf {
|
|
5
5
|
memberOf: true;
|
|
6
6
|
}
|
|
7
7
|
export declare class MemberOf extends Attestation<IMemberOf> {
|
|
8
8
|
details?: MemberDetails;
|
|
9
9
|
multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("..").GapSchema>, import("core/types").RawMultiAttestPayload][]>;
|
|
10
|
-
attest(signer: SignerOrProvider, callback?: Function): Promise<
|
|
10
|
+
attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
|
|
11
11
|
}
|
|
@@ -16,15 +16,17 @@ class MemberOf extends Attestation_1.Attestation {
|
|
|
16
16
|
async attest(signer, callback) {
|
|
17
17
|
const payload = await this.multiAttestPayload();
|
|
18
18
|
try {
|
|
19
|
-
const
|
|
19
|
+
const { uids, tx } = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
20
|
+
const [memberUID, detailsUID] = uids;
|
|
20
21
|
this.uid = memberUID;
|
|
21
22
|
if (this.details && detailsUID) {
|
|
22
23
|
this.details.uid = detailsUID;
|
|
23
24
|
}
|
|
25
|
+
return { tx, uids };
|
|
24
26
|
}
|
|
25
27
|
catch (error) {
|
|
26
28
|
console.error(error);
|
|
27
|
-
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
|
|
29
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "ethers";
|
|
1
2
|
import { MultiAttestPayload, SignerOrProvider, TNetwork } from "../../types";
|
|
2
3
|
import { Attestation } from "../Attestation";
|
|
3
4
|
import { GapSchema } from "../GapSchema";
|
|
4
5
|
import { IMilestoneResponse } from "../karma-indexer/api/types";
|
|
5
|
-
import { MilestoneCompleted } from "../types/attestations";
|
|
6
|
+
import { AttestationWithTx, MilestoneCompleted, IMilestoneCompleted } from "../types/attestations";
|
|
6
7
|
export interface IMilestone {
|
|
7
8
|
title: string;
|
|
8
9
|
startsAt?: number;
|
|
@@ -26,7 +27,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
26
27
|
* @param signer
|
|
27
28
|
* @param reason
|
|
28
29
|
*/
|
|
29
|
-
approve(signer: SignerOrProvider,
|
|
30
|
+
approve(signer: SignerOrProvider, data?: IMilestoneCompleted, callback?: Function): Promise<void>;
|
|
30
31
|
/**
|
|
31
32
|
* Revokes the approved status of the milestone. If the milestone is not approved,
|
|
32
33
|
* it will throw an error.
|
|
@@ -45,20 +46,26 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
45
46
|
* it will throw an error.
|
|
46
47
|
* @param signer
|
|
47
48
|
*/
|
|
48
|
-
revokeRejection(signer: SignerOrProvider): Promise<
|
|
49
|
+
revokeRejection(signer: SignerOrProvider): Promise<{
|
|
50
|
+
tx: Transaction[];
|
|
51
|
+
uids: `0x${string}`[];
|
|
52
|
+
}>;
|
|
49
53
|
/**
|
|
50
54
|
* Marks a milestone as completed. If the milestone is already completed,
|
|
51
55
|
* it will throw an error.
|
|
52
56
|
* @param signer
|
|
53
57
|
* @param reason
|
|
54
58
|
*/
|
|
55
|
-
complete(signer: SignerOrProvider,
|
|
59
|
+
complete(signer: SignerOrProvider, data?: IMilestoneCompleted, callback?: Function): Promise<AttestationWithTx>;
|
|
56
60
|
/**
|
|
57
61
|
* Revokes the completed status of the milestone. If the milestone is not completed,
|
|
58
62
|
* it will throw an error.
|
|
59
63
|
* @param signer
|
|
60
64
|
*/
|
|
61
|
-
revokeCompletion(signer: SignerOrProvider, callback?: Function): Promise<
|
|
65
|
+
revokeCompletion(signer: SignerOrProvider, callback?: Function): Promise<{
|
|
66
|
+
tx: Transaction[];
|
|
67
|
+
uids: `0x${string}`[];
|
|
68
|
+
}>;
|
|
62
69
|
/**
|
|
63
70
|
* Creates the payload for a multi-attestation.
|
|
64
71
|
*
|
|
@@ -73,7 +80,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
73
80
|
/**
|
|
74
81
|
* @inheritdoc
|
|
75
82
|
*/
|
|
76
|
-
attest(signer: SignerOrProvider, callback?: Function): Promise<
|
|
83
|
+
attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
|
|
77
84
|
/**
|
|
78
85
|
* Attest the status of the milestone as approved, rejected or completed.
|
|
79
86
|
*/
|
|
@@ -85,5 +92,5 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
85
92
|
* @param signer
|
|
86
93
|
* @param reason
|
|
87
94
|
*/
|
|
88
|
-
verify(signer: SignerOrProvider,
|
|
95
|
+
verify(signer: SignerOrProvider, data?: IMilestoneCompleted, callback?: Function): Promise<AttestationWithTx>;
|
|
89
96
|
}
|