@show-karma/karma-gap-sdk 0.1.29
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/MultiAttester.json +676 -0
- package/core/class/Attestation.d.ts +169 -0
- package/core/class/Attestation.js +311 -0
- package/core/class/Fetcher.d.ts +132 -0
- package/core/class/Fetcher.js +7 -0
- package/core/class/GAP.d.ts +212 -0
- package/core/class/GAP.js +206 -0
- package/core/class/GapSchema.d.ts +33 -0
- package/core/class/GapSchema.js +61 -0
- package/core/class/Gelato/Gelato.d.ts +0 -0
- package/core/class/Gelato/Gelato.js +263 -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/Fetcher.d.ts +132 -0
- package/core/class/GraphQL/Fetcher.js +7 -0
- package/core/class/GraphQL/GAPFetcher.d.ts +160 -0
- package/core/class/GraphQL/GAPFetcher.js +516 -0
- package/core/class/GraphQL/GapEasClient.d.ts +63 -0
- package/core/class/GraphQL/GapEasClient.js +420 -0
- package/core/class/GraphQL/index.d.ts +3 -0
- package/core/class/GraphQL/index.js +19 -0
- package/core/class/Schema.d.ts +213 -0
- package/core/class/Schema.js +434 -0
- package/core/class/SchemaError.d.ts +26 -0
- package/core/class/SchemaError.js +34 -0
- package/core/class/contract/GapContract.d.ts +55 -0
- package/core/class/contract/GapContract.js +176 -0
- package/core/class/contract/MultiAttest.d.ts +10 -0
- package/core/class/contract/MultiAttest.js +19 -0
- package/core/class/entities/Community.d.ts +36 -0
- package/core/class/entities/Community.js +88 -0
- package/core/class/entities/Grant.d.ts +53 -0
- package/core/class/entities/Grant.js +194 -0
- package/core/class/entities/MemberOf.d.ts +11 -0
- package/core/class/entities/MemberOf.js +31 -0
- package/core/class/entities/Milestone.d.ts +63 -0
- package/core/class/entities/Milestone.js +171 -0
- package/core/class/entities/Project.d.ts +73 -0
- package/core/class/entities/Project.js +243 -0
- package/core/class/entities/index.d.ts +5 -0
- package/core/class/entities/index.js +21 -0
- package/core/class/index.d.ts +7 -0
- package/core/class/index.js +23 -0
- package/core/class/karma-indexer/GapIndexerClient.d.ts +28 -0
- package/core/class/karma-indexer/GapIndexerClient.js +137 -0
- package/core/class/types/attestations.d.ts +108 -0
- package/core/class/types/attestations.js +55 -0
- package/core/consts.d.ts +19 -0
- package/core/consts.js +228 -0
- package/core/index.d.ts +7 -0
- package/core/index.js +23 -0
- package/core/types.d.ts +107 -0
- package/core/types.js +13 -0
- package/core/utils/gelato/index.d.ts +3 -0
- package/core/utils/gelato/index.js +19 -0
- package/core/utils/gelato/send-gelato-txn.d.ts +54 -0
- package/core/utils/gelato/send-gelato-txn.js +99 -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 +55 -0
- package/core/utils/get-date.d.ts +1 -0
- package/core/utils/get-date.js +7 -0
- package/core/utils/gql-queries.d.ts +12 -0
- package/core/utils/gql-queries.js +90 -0
- package/core/utils/index.d.ts +6 -0
- package/core/utils/index.js +22 -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.d.ts +1 -0
- package/index.js +17 -0
- package/package.json +37 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// /* eslint-disable no-shadow */
|
|
2
|
+
// /* eslint-disable no-promise-executor-return */
|
|
3
|
+
// /* eslint-disable no-await-in-loop */
|
|
4
|
+
// /* eslint-disable id-length */
|
|
5
|
+
// /* eslint-disable class-methods-use-this */
|
|
6
|
+
// /* eslint-disable no-useless-constructor */
|
|
7
|
+
// /* eslint-disable import/no-extraneous-dependencies */
|
|
8
|
+
// import { GelatoRelay } from "@gelatonetwork/relay-sdk";
|
|
9
|
+
// import { ethers } from "ethers";
|
|
10
|
+
// import axios from "axios";
|
|
11
|
+
// import ABI from "./";
|
|
12
|
+
// import { Hex } from "core/types";
|
|
13
|
+
// enum TaskState {
|
|
14
|
+
// CheckPending = "CheckPending",
|
|
15
|
+
// ExecPending = "ExecPending",
|
|
16
|
+
// ExecSuccess = "ExecSuccess",
|
|
17
|
+
// ExecReverted = "ExecReverted",
|
|
18
|
+
// WaitingForConfirmation = "WaitingForConfirmation",
|
|
19
|
+
// Blacklisted = "Blacklisted",
|
|
20
|
+
// Cancelled = "Cancelled",
|
|
21
|
+
// NotFound = "NotFound",
|
|
22
|
+
// }
|
|
23
|
+
// export class DelegateRegistryContract extends GelatoRelay {
|
|
24
|
+
// contract: ethers.Contract;
|
|
25
|
+
// constructor(readonly contractAddress: Hex) {
|
|
26
|
+
// super();
|
|
27
|
+
// this.contract = new ethers.Contract(contractAddress, ABI);
|
|
28
|
+
// }
|
|
29
|
+
// /**
|
|
30
|
+
// * Returns the r, s, v values of a signature
|
|
31
|
+
// * @param signature
|
|
32
|
+
// * @returns
|
|
33
|
+
// */
|
|
34
|
+
// private getRSV(signature: string) {
|
|
35
|
+
// const r = signature.slice(0, 66);
|
|
36
|
+
// const s = `0x${signature.slice(66, 130)}`;
|
|
37
|
+
// const v = `0x${signature.slice(130, 132)}`;
|
|
38
|
+
// return { r, s, v };
|
|
39
|
+
// }
|
|
40
|
+
// /**
|
|
41
|
+
// * Returns the nonce of a delegate
|
|
42
|
+
// * @param address
|
|
43
|
+
// * @returns
|
|
44
|
+
// */
|
|
45
|
+
// async getNonce(address: Hex) {
|
|
46
|
+
// const nonce = <bigint>await readFn({
|
|
47
|
+
// abi: ABI,
|
|
48
|
+
// address: this.contractAddress,
|
|
49
|
+
// functionName: "nonces",
|
|
50
|
+
// args: [address],
|
|
51
|
+
// chainId: 10,
|
|
52
|
+
// });
|
|
53
|
+
// return {
|
|
54
|
+
// nonce: Number(nonce),
|
|
55
|
+
// next: Number(nonce + 1n),
|
|
56
|
+
// };
|
|
57
|
+
// }
|
|
58
|
+
// /**
|
|
59
|
+
// * Waits for a transaction to be mined at Gelato Network
|
|
60
|
+
// * @param taskId
|
|
61
|
+
// * @returns
|
|
62
|
+
// */
|
|
63
|
+
// wait(taskId: string): Promise<string> {
|
|
64
|
+
// return new Promise((resolve, reject) => {
|
|
65
|
+
// const loop = async () => {
|
|
66
|
+
// const oneSecond = 1;
|
|
67
|
+
// while (oneSecond) {
|
|
68
|
+
// const status = await this.getTaskStatus(taskId);
|
|
69
|
+
// // print status :D so we can debug this for now
|
|
70
|
+
// // eslint-disable-next-line no-console
|
|
71
|
+
// console.log(status);
|
|
72
|
+
// if (!status) {
|
|
73
|
+
// reject(new Error("Transaction goes wrong."));
|
|
74
|
+
// break;
|
|
75
|
+
// }
|
|
76
|
+
// if (status && status.taskState === TaskState.ExecSuccess) {
|
|
77
|
+
// resolve(status.transactionHash || "");
|
|
78
|
+
// break;
|
|
79
|
+
// } else if (
|
|
80
|
+
// [
|
|
81
|
+
// TaskState.Cancelled,
|
|
82
|
+
// TaskState.ExecReverted,
|
|
83
|
+
// TaskState.Blacklisted,
|
|
84
|
+
// ].includes(status?.taskState)
|
|
85
|
+
// ) {
|
|
86
|
+
// reject(
|
|
87
|
+
// new Error(
|
|
88
|
+
// status.lastCheckMessage
|
|
89
|
+
// ?.split(/(RegisterDelegate)|(Execution error): /)
|
|
90
|
+
// .at(-1) || ""
|
|
91
|
+
// )
|
|
92
|
+
// );
|
|
93
|
+
// break;
|
|
94
|
+
// }
|
|
95
|
+
// await new Promise((r) => setTimeout(r, 500));
|
|
96
|
+
// }
|
|
97
|
+
// };
|
|
98
|
+
// loop();
|
|
99
|
+
// });
|
|
100
|
+
// }
|
|
101
|
+
// /**
|
|
102
|
+
// * Executes a transaction on the DelegateRegistry contract
|
|
103
|
+
// * @param fn the function to call
|
|
104
|
+
// * @param args the arguments to pass to the function
|
|
105
|
+
// * @returns the transaction hash and a wait function to wait for the transaction to be mined
|
|
106
|
+
// */
|
|
107
|
+
// public async transaction(fn: string, args: unknown[]) {
|
|
108
|
+
// const { hash } = await writeFn({
|
|
109
|
+
// abi: ABI,
|
|
110
|
+
// address: this.contractAddress,
|
|
111
|
+
// functionName: fn,
|
|
112
|
+
// args,
|
|
113
|
+
// chainId: 10,
|
|
114
|
+
// });
|
|
115
|
+
// return {
|
|
116
|
+
// hash,
|
|
117
|
+
// wait: () => waitForTransaction({ hash }),
|
|
118
|
+
// };
|
|
119
|
+
// }
|
|
120
|
+
// public async registerDelegate(data: DelegateWithProfile) {
|
|
121
|
+
// return this.transaction("registerDelegate", [
|
|
122
|
+
// data.tokenAddress,
|
|
123
|
+
// BigInt(data.tokenChainId),
|
|
124
|
+
// JSON.stringify(data.profile),
|
|
125
|
+
// ]);
|
|
126
|
+
// }
|
|
127
|
+
// /**
|
|
128
|
+
// * Creates the payload for register delegate by signature
|
|
129
|
+
// * returning the payload
|
|
130
|
+
// * @param data
|
|
131
|
+
// * @returns
|
|
132
|
+
// */
|
|
133
|
+
// public async registerDelegateBySig(
|
|
134
|
+
// address: Hex,
|
|
135
|
+
// data: DelegateWithProfile
|
|
136
|
+
// ): Promise<Parameters<GelatoRelay["sponsoredCall"]>> {
|
|
137
|
+
// const { nonce } = await this.getNonce(address);
|
|
138
|
+
// // 2 minutes expiry
|
|
139
|
+
// const expiry = ((Date.now() + 1000 * 120) / 1000).toFixed(0);
|
|
140
|
+
// const metadata = JSON.stringify(data.profile);
|
|
141
|
+
// const types = {
|
|
142
|
+
// RegisterDelegate: [
|
|
143
|
+
// { name: "tokenAddress", type: "address" },
|
|
144
|
+
// { name: "tokenChainId", type: "uint256" },
|
|
145
|
+
// { name: "metadata", type: "string" },
|
|
146
|
+
// { name: "nonce", type: "uint256" },
|
|
147
|
+
// { name: "expiry", type: "uint256" },
|
|
148
|
+
// ],
|
|
149
|
+
// } as const;
|
|
150
|
+
// const signature = await signTypedData({
|
|
151
|
+
// message: {
|
|
152
|
+
// tokenAddress: data.tokenAddress,
|
|
153
|
+
// tokenChainId: BigInt(data.tokenChainId),
|
|
154
|
+
// metadata,
|
|
155
|
+
// nonce,
|
|
156
|
+
// expiry,
|
|
157
|
+
// },
|
|
158
|
+
// domain: {
|
|
159
|
+
// name: "delegate-registry",
|
|
160
|
+
// version: "1.0",
|
|
161
|
+
// chainId: data.tokenChainId,
|
|
162
|
+
// verifyingContract: this.contractAddress,
|
|
163
|
+
// },
|
|
164
|
+
// primaryType: "RegisterDelegate",
|
|
165
|
+
// types,
|
|
166
|
+
// });
|
|
167
|
+
// const { r, s, v } = this.getRSV(signature);
|
|
168
|
+
// const { data: payload } =
|
|
169
|
+
// await this.contract.populateTransaction.registerDelegateBySig(
|
|
170
|
+
// address,
|
|
171
|
+
// data.tokenAddress,
|
|
172
|
+
// BigInt(data.tokenChainId),
|
|
173
|
+
// metadata,
|
|
174
|
+
// nonce,
|
|
175
|
+
// expiry,
|
|
176
|
+
// v,
|
|
177
|
+
// r,
|
|
178
|
+
// s
|
|
179
|
+
// );
|
|
180
|
+
// // eslint-disable-next-line no-console
|
|
181
|
+
// console.log({ payload, signature, r, s, v });
|
|
182
|
+
// if (!payload) throw new Error("Payload is undefined");
|
|
183
|
+
// return [
|
|
184
|
+
// {
|
|
185
|
+
// data: payload,
|
|
186
|
+
// chainId: 10,
|
|
187
|
+
// target: this.contractAddress,
|
|
188
|
+
// },
|
|
189
|
+
// "{apiKey}", // filled in the api
|
|
190
|
+
// {
|
|
191
|
+
// retries: 3,
|
|
192
|
+
// },
|
|
193
|
+
// ];
|
|
194
|
+
// }
|
|
195
|
+
// /**
|
|
196
|
+
// * Sends a sponsored call to the DelegateRegistry contract using GelatoRelay
|
|
197
|
+
// * @param payload
|
|
198
|
+
// * @returns
|
|
199
|
+
// */
|
|
200
|
+
// static async sendGelato(...params: Parameters<GelatoRelay["sponsoredCall"]>) {
|
|
201
|
+
// const client = new this(params[0].target as Hex);
|
|
202
|
+
// const relayResponse = await client.sponsoredCall(...params);
|
|
203
|
+
// return {
|
|
204
|
+
// taskId: relayResponse.taskId,
|
|
205
|
+
// wait: () => client.wait(relayResponse.taskId),
|
|
206
|
+
// };
|
|
207
|
+
// }
|
|
208
|
+
// /**
|
|
209
|
+
// * Deregisters a delegate on the DelegateRegistry contract
|
|
210
|
+
// * @param tokenAddress
|
|
211
|
+
// * @param tokenChainId
|
|
212
|
+
// * @returns
|
|
213
|
+
// */
|
|
214
|
+
// public deregisterDelegate(tokenAddress: string, tokenChainId: number) {
|
|
215
|
+
// return this.transaction("deregisterDelegate", [tokenAddress, tokenChainId]);
|
|
216
|
+
// }
|
|
217
|
+
// /**
|
|
218
|
+
// * Returns a delegate from the DelegateRegistry contract
|
|
219
|
+
// * @param delegateAddress
|
|
220
|
+
// * @param tokenAddress
|
|
221
|
+
// * @param tokenChainId
|
|
222
|
+
// * @returns
|
|
223
|
+
// */
|
|
224
|
+
// static async getDelegate(
|
|
225
|
+
// addresses: string[],
|
|
226
|
+
// tokenAddress: string,
|
|
227
|
+
// tokenChainId: number
|
|
228
|
+
// ): Promise<DelegateRegistryWithInterests[]> {
|
|
229
|
+
// const query = `
|
|
230
|
+
// {
|
|
231
|
+
// delegates(where: { delegateAddress_in: ["${addresses.join(
|
|
232
|
+
// '","'
|
|
233
|
+
// )}"], tokenAddress: "${tokenAddress}", tokenChainId: ${tokenChainId} }) {
|
|
234
|
+
// id
|
|
235
|
+
// delegateAddress
|
|
236
|
+
// tokenAddress
|
|
237
|
+
// tokenChainId
|
|
238
|
+
// statement
|
|
239
|
+
// status
|
|
240
|
+
// blockTimestamp
|
|
241
|
+
// name
|
|
242
|
+
// ipfsMetadata
|
|
243
|
+
// acceptedCoC
|
|
244
|
+
// interests
|
|
245
|
+
// }
|
|
246
|
+
// }`;
|
|
247
|
+
// const {
|
|
248
|
+
// data: {
|
|
249
|
+
// data: { delegates },
|
|
250
|
+
// },
|
|
251
|
+
// } = await axios.post<{ data: DelegateStatementRes }>(this.subgraphUrl, {
|
|
252
|
+
// query,
|
|
253
|
+
// });
|
|
254
|
+
// return delegates.map((item) => {
|
|
255
|
+
// if (Array.isArray(item?.interests))
|
|
256
|
+
// return item as DelegateRegistryWithInterests;
|
|
257
|
+
// return <DelegateRegistryWithInterests>{
|
|
258
|
+
// ...item,
|
|
259
|
+
// interests: item.interests?.split(",") || [],
|
|
260
|
+
// };
|
|
261
|
+
// });
|
|
262
|
+
// }
|
|
263
|
+
// }
|
|
@@ -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,132 @@
|
|
|
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 "./AxiosGQL";
|
|
6
|
+
export declare abstract class Fetcher extends AxiosGQL {
|
|
7
|
+
/**
|
|
8
|
+
* Fetch a single attestation by its UID.
|
|
9
|
+
* @param uid
|
|
10
|
+
*/
|
|
11
|
+
abstract attestation<T = unknown>(uid: Hex): Promise<Attestation<T>>;
|
|
12
|
+
/**
|
|
13
|
+
* Fetch attestations of a schema.
|
|
14
|
+
* @param schemaName
|
|
15
|
+
* @param search if set, will search decodedDataJson by the value.
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
abstract attestations(schemaName: TSchemaName, search?: string): Promise<IAttestation[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch attestations of a schema.
|
|
21
|
+
* @param schemaName
|
|
22
|
+
* @param recipient
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
abstract attestationsOf(schemaName: TSchemaName, recipient: Hex): Promise<IAttestation[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch attestations of a schema for a specific recipient.
|
|
28
|
+
* @param schemaName
|
|
29
|
+
* @param recipient
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
abstract attestationsTo(schemaName: TSchemaName, recipient: Hex): Promise<IAttestation[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Fetch all available communities with details and grantees uids.
|
|
35
|
+
*
|
|
36
|
+
* If search is defined, will try to find communities by the search string.
|
|
37
|
+
* @param search
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
abstract communities(search?: string): Promise<Community[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetch a set of communities by their ids.
|
|
43
|
+
* @param uids
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
abstract communitiesByIds(uids: Hex[]): Promise<Community[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Fetch a community by its name with details, grants and milestones.
|
|
49
|
+
*
|
|
50
|
+
* It is possible that the resulted community is not the one you are looking for.
|
|
51
|
+
* @param name
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
abstract communityBySlug(slug: string): Promise<Community>;
|
|
55
|
+
/**
|
|
56
|
+
* Fetch a community by its id. This method will also return the
|
|
57
|
+
* community details and projects.
|
|
58
|
+
*/
|
|
59
|
+
abstract communityById(uid: Hex): Promise<Community>;
|
|
60
|
+
/**
|
|
61
|
+
* Fetch a project by its id.
|
|
62
|
+
* @param uid
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
abstract projectById(uid: Hex): Promise<Project>;
|
|
66
|
+
/**
|
|
67
|
+
* Fetch a project by its slug.
|
|
68
|
+
* @param slug
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
abstract projectBySlug(slug: string): Promise<Project>;
|
|
72
|
+
/**
|
|
73
|
+
* Fetch projects with details and members.
|
|
74
|
+
* @param name if set, will search by the name.
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
abstract projects(name?: string): Promise<Project[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Fetch projects with details and members.
|
|
80
|
+
* @param grantee the public address of the grantee
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
abstract projectsOf(grantee: Hex): Promise<Project[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Fetch Grantee with details and projects.
|
|
86
|
+
* @param address
|
|
87
|
+
* @param withProjects if true, will get grantee project details.
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
abstract grantee(address: Hex): Promise<Grantee>;
|
|
91
|
+
/**
|
|
92
|
+
* Fetch all Grantees with details.
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
abstract grantees(): Promise<Grantee[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Fetches the grantes related to a grantee address (recipient).
|
|
98
|
+
* @param grantee grantee address
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
abstract grantsOf(grantee: Hex, withCommunity?: boolean): Promise<Grant[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Fetch grants for an array of projects with milestones.
|
|
104
|
+
* @param projects
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
abstract grantsFor(projects: Project[], withCommunity?: boolean): Promise<Grant[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Fetch a grants that belongs to a community.
|
|
110
|
+
* @param uid community uid
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
abstract grantsByCommunity(uid: Hex): any;
|
|
114
|
+
/**
|
|
115
|
+
* Fetch all milestones related to an array of Grants.
|
|
116
|
+
* @param grants
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
abstract milestonesOf(grants: Grant[]): Promise<Milestone[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Bulk fetch members with details of an array of Projects.
|
|
122
|
+
* @param projects
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
125
|
+
abstract membersOf(projects: Project[]): Promise<MemberOf[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Check if a name is already in use.
|
|
128
|
+
* @param slug
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
abstract slugExists(slug: string): Promise<boolean>;
|
|
132
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Attestation } from "../Attestation";
|
|
2
|
+
import { Hex, IAttestation, TSchemaName } from "../../types";
|
|
3
|
+
import { Grantee } from "../types/attestations";
|
|
4
|
+
import { GapSchema } from "../GapSchema";
|
|
5
|
+
import { EASClient } from "./EASClient";
|
|
6
|
+
import { Grant, Milestone, Project, MemberOf } from "../entities";
|
|
7
|
+
import { Community } from "../entities/Community";
|
|
8
|
+
export declare class GAPFetcher extends EASClient {
|
|
9
|
+
/**
|
|
10
|
+
* Fetches all the schemas deployed by an owner
|
|
11
|
+
* @param owner
|
|
12
|
+
*/
|
|
13
|
+
schemas(owner: Hex): Promise<GapSchema[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetch a single attestation by its UID.
|
|
16
|
+
* @param uid
|
|
17
|
+
*/
|
|
18
|
+
attestation<T = unknown>(uid: Hex): Promise<Attestation<T, GapSchema>>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch attestations of a schema.
|
|
21
|
+
* @param schemaName
|
|
22
|
+
* @param search if set, will search decodedDataJson by the value.
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
attestations(schemaName: TSchemaName, search?: string): Promise<IAttestation[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch attestations of a schema.
|
|
28
|
+
* @param schemaName
|
|
29
|
+
* @param recipient
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
attestationsOf(schemaName: TSchemaName, recipient: Hex): Promise<IAttestation[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Fetch attestations of a schema for a specific recipient.
|
|
35
|
+
* @param schemaName
|
|
36
|
+
* @param recipient
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
attestationsTo(schemaName: TSchemaName, recipient: Hex): Promise<IAttestation[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Fetch all dependent attestations of a parent schema.
|
|
42
|
+
* @param parentSchema the schema name to get dependents of.
|
|
43
|
+
* @param parentUid the parent uid to get dependents of.
|
|
44
|
+
*/
|
|
45
|
+
dependentsOf(parentSchema: TSchemaName, parentUid: Hex): Promise<Attestation[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Fetch all available communities with details and grantees uids.
|
|
48
|
+
*
|
|
49
|
+
* If search is defined, will try to find communities by the search string.
|
|
50
|
+
* @param search
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
communities(search?: string): Promise<Community[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Fetch a set of communities by their ids.
|
|
56
|
+
* @param uids
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
communitiesByIds(uids: Hex[]): Promise<Community[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Get details for a set of communities and returns the updated array.
|
|
62
|
+
* @param communities
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
communitiesDetails(communities: Community[]): Promise<Community[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Fetch a community by its name with details, grants and milestones.
|
|
68
|
+
*
|
|
69
|
+
* It is possible that the resulted community is not the one you are looking for.
|
|
70
|
+
* @param name
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
communityBySlug(slug: string): Promise<Community>;
|
|
74
|
+
/**
|
|
75
|
+
* Fetch a community by its id. This method will also return the
|
|
76
|
+
* community details and projects.
|
|
77
|
+
*/
|
|
78
|
+
communityById(uid: Hex): Promise<Community>;
|
|
79
|
+
/**
|
|
80
|
+
* Fetch the details for a set of
|
|
81
|
+
* projects with project grants,
|
|
82
|
+
* members, milestones, and tags.
|
|
83
|
+
* @param projects
|
|
84
|
+
*/
|
|
85
|
+
projectsDetails(projects: Project[]): Promise<Project[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch a project by its id.
|
|
88
|
+
* @param uid
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
projectById(uid: Hex): Promise<Project>;
|
|
92
|
+
/**
|
|
93
|
+
* Fetch a project by its id.
|
|
94
|
+
* @param uid
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
projectBySlug(slug: string): Promise<Project>;
|
|
98
|
+
/**
|
|
99
|
+
* Check if a name is already in use.
|
|
100
|
+
* @param slug
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
slugExists(slug: string): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Fetch projects with details and members.
|
|
106
|
+
* @param name if set, will search by the name.
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
projects(name?: string): Promise<Project[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Fetch projects with details and members.
|
|
112
|
+
* @param grantee the public address of the grantee
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
projectsOf(grantee: Hex): Promise<Project[]>;
|
|
116
|
+
/**
|
|
117
|
+
* Fetch Grantee with details and projects.
|
|
118
|
+
* @param address
|
|
119
|
+
* @param withProjects if true, will get grantee project details.
|
|
120
|
+
* @returns
|
|
121
|
+
*/
|
|
122
|
+
grantee(address: Hex): Promise<Grantee>;
|
|
123
|
+
/**
|
|
124
|
+
* Fetch all Grantees with details.
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
grantees(): Promise<Grantee[]>;
|
|
128
|
+
/**
|
|
129
|
+
* Fetches the grantes related to a grantee address (recipient).
|
|
130
|
+
* @param grantee
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
grantsOf(grantee: Hex, withCommunity?: boolean): Promise<Grant[]>;
|
|
134
|
+
grantsUpdates(grants: Grant[]): Promise<Grant[]>;
|
|
135
|
+
grantsByCommunity(uid: Hex): Promise<Grant[]>;
|
|
136
|
+
/**
|
|
137
|
+
* Fetch grants for an array of projects with milestones.
|
|
138
|
+
* @param projects
|
|
139
|
+
* @returns
|
|
140
|
+
*/
|
|
141
|
+
grantsFor(projects: Project[], withCommunity?: boolean): Promise<Grant[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Fetch all milestones related to an array of Grants.
|
|
144
|
+
* @param grants
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
milestonesOf(grants: Grant[]): Promise<Milestone[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Bulk fetch members with details of an array of Projects.
|
|
150
|
+
* @param projects
|
|
151
|
+
* @returns
|
|
152
|
+
*/
|
|
153
|
+
membersOf(projects: Project[]): Promise<MemberOf[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Returns a string to be used to search by a value in `decodedDataJson`.
|
|
156
|
+
* @param field
|
|
157
|
+
* @param value
|
|
158
|
+
*/
|
|
159
|
+
private getSearchFieldString;
|
|
160
|
+
}
|