@show-karma/karma-gap-sdk 0.3.4 → 0.3.5
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/CommunityResolverABI.json +508 -0
- package/core/class/AttestationIPFS.d.ts +7 -0
- package/core/class/AttestationIPFS.js +10 -0
- package/core/class/GAP.d.ts +7 -0
- package/core/class/GAP.js +14 -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/IPFS/IPFS.d.ts +13 -0
- package/core/class/IPFS/IPFS.js +24 -0
- package/core/class/contract/MultiAttest.d.ts +10 -0
- package/core/class/contract/MultiAttest.js +19 -0
- package/core/consts.js +4 -34
- package/core/types.d.ts +1 -0
- package/package.json +1 -1
- package/readme.md +34 -39
- package/config/keys.example.json +0 -6
- package/core/abi/EAS.json +0 -1
- package/core/abi/SchemaRegistry.json +0 -1
- package/core/class/Attestation.ts +0 -402
- package/core/class/Fetcher.ts +0 -202
- package/core/class/GAP.ts +0 -398
- package/core/class/GapSchema.ts +0 -90
- package/core/class/Gelato/Gelato.ts +0 -286
- package/core/class/GraphQL/AxiosGQL.ts +0 -29
- package/core/class/GraphQL/EASClient.ts +0 -34
- package/core/class/GraphQL/GapEasClient.ts +0 -845
- package/core/class/GraphQL/index.ts +0 -3
- package/core/class/Schema.ts +0 -609
- package/core/class/SchemaError.ts +0 -36
- package/core/class/contract/GapContract.ts +0 -353
- package/core/class/entities/Community.ts +0 -115
- package/core/class/entities/Grant.ts +0 -309
- package/core/class/entities/MemberOf.ts +0 -42
- package/core/class/entities/Milestone.ts +0 -269
- package/core/class/entities/Project.ts +0 -370
- package/core/class/entities/index.ts +0 -5
- package/core/class/index.ts +0 -10
- package/core/class/karma-indexer/GapIndexerClient.ts +0 -245
- package/core/class/remote-storage/IpfsStorage.ts +0 -51
- package/core/class/remote-storage/RemoteStorage.ts +0 -65
- package/core/class/types/attestations.ts +0 -158
- package/core/consts.ts +0 -282
- package/core/index.ts +0 -7
- package/core/scripts/deploy.ts +0 -67
- package/core/scripts/index.ts +0 -1
- package/core/types.ts +0 -186
- package/core/utils/gelato/index.ts +0 -3
- 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 -20
- package/core/utils/gql-queries.ts +0 -133
- package/core/utils/index.ts +0 -7
- 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/csv-upload/.gitkeep +0 -0
- package/csv-upload/example.csv +0 -2
- package/csv-upload/scripts/run.ts +0 -193
- package/docs/.gitkeep +0 -0
- package/docs/images/attestation-architecture.png +0 -0
- package/docs/images/dfd-get-projects.png +0 -0
- package/index.ts +0 -1
- package/schemas/.gitkeep +0 -0
- package/schemas/GAP-schemas-1692135812877.json +0 -33
- package/test-file.ts +0 -92
- package/tsconfig.json +0 -26
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as csv from 'fast-csv';
|
|
3
|
-
import {
|
|
4
|
-
GapSchema,
|
|
5
|
-
GrantDetails,
|
|
6
|
-
GrantUpdate,
|
|
7
|
-
Hex,
|
|
8
|
-
MultiAttestPayload,
|
|
9
|
-
Project,
|
|
10
|
-
ProjectDetails,
|
|
11
|
-
RawMultiAttestPayload,
|
|
12
|
-
} from '../../core';
|
|
13
|
-
import { isAddress } from 'ethers/lib/utils';
|
|
14
|
-
import { ethers } from 'ethers';
|
|
15
|
-
import { GAP, GapIndexerClient, Grant, MemberOf } from '../../core/class';
|
|
16
|
-
import { GapContract } from '../../core/class/contract/GapContract';
|
|
17
|
-
|
|
18
|
-
const [, , fileName, communityUID] = process.argv;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Secret keys
|
|
22
|
-
*/
|
|
23
|
-
const { optimismGoerli: key, gelatoApiKey, alchemy } = require(__dirname +
|
|
24
|
-
'/../../config/keys.json');
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Mainnet provider to resolve ens names
|
|
28
|
-
*/
|
|
29
|
-
const mainnetProviderUrl = alchemy;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* web3 provider to build wallet and sign transactions
|
|
33
|
-
*/
|
|
34
|
-
const web3 = new ethers.providers.JsonRpcProvider(
|
|
35
|
-
'https://goerli.optimism.io'
|
|
36
|
-
// "https://eth-sepolia-public.unifra.io"
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Wallet to sign transactions
|
|
41
|
-
*/
|
|
42
|
-
const wallet = new ethers.Wallet(key, web3);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* GAP client
|
|
46
|
-
*/
|
|
47
|
-
const gap = new GAP({
|
|
48
|
-
network: 'optimism-goerli',
|
|
49
|
-
apiClient: new GapIndexerClient('https://gapapi.karmahq.xyz'),
|
|
50
|
-
gelatoOpts: {
|
|
51
|
-
// sponsorUrl: 'http://localhost:3001/attestations/sponsored-txn',
|
|
52
|
-
apiKey: gelatoApiKey,
|
|
53
|
-
useGasless: true,
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Ethers client to resolve ens names
|
|
59
|
-
*/
|
|
60
|
-
const ens = new ethers.providers.JsonRpcProvider(mainnetProviderUrl);
|
|
61
|
-
|
|
62
|
-
interface CSV {
|
|
63
|
-
URL: string;
|
|
64
|
-
Name: string;
|
|
65
|
-
Owner: string;
|
|
66
|
-
Twitter: string;
|
|
67
|
-
Github: string;
|
|
68
|
-
Website: string;
|
|
69
|
-
'Project Description': string;
|
|
70
|
-
'Grant Update': string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function parseCsv<T>(
|
|
74
|
-
path: string,
|
|
75
|
-
parserFn?: (row: unknown) => Promise<void> | void
|
|
76
|
-
): Promise<T[]> {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
const res: T[] = [];
|
|
79
|
-
fs.createReadStream(path)
|
|
80
|
-
.pipe(csv.parse({ headers: true }))
|
|
81
|
-
.transform((row: unknown) => {
|
|
82
|
-
return row;
|
|
83
|
-
})
|
|
84
|
-
.on('data', (d) => res.push(parserFn ? parserFn(d) : d))
|
|
85
|
-
.on('error', reject)
|
|
86
|
-
.on('end', () => {
|
|
87
|
-
resolve(res);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const isEns = (str: string) => /^\w+\.(eth)$/.test(str);
|
|
93
|
-
const isHex = (str: string): str is Hex => /^0x[a-fA-F0-9]{64}$/.test(str);
|
|
94
|
-
|
|
95
|
-
async function bootstrap() {
|
|
96
|
-
let uids: Hex[] = [];
|
|
97
|
-
|
|
98
|
-
if (!fileName || !fileName.endsWith('.csv'))
|
|
99
|
-
throw new Error('Please provide a valid csv file name');
|
|
100
|
-
|
|
101
|
-
if (!communityUID || !isHex(communityUID))
|
|
102
|
-
throw new Error('Please provide a valid community UID');
|
|
103
|
-
|
|
104
|
-
const file = __dirname + `/../${fileName}`;
|
|
105
|
-
|
|
106
|
-
const data = await parseCsv<CSV>(file);
|
|
107
|
-
const filtered = data.filter((d) => isAddress(d.Owner) || isEns(d.Owner));
|
|
108
|
-
|
|
109
|
-
for (const item of filtered) {
|
|
110
|
-
let address = item.Owner;
|
|
111
|
-
if (isEns(item.Owner)) {
|
|
112
|
-
address = (await ens.resolveName(item.Owner)) || address;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const project = new Project({
|
|
116
|
-
data: { project: true },
|
|
117
|
-
recipient: address as Hex,
|
|
118
|
-
schema: gap.findSchema('Project'),
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
project.details = new ProjectDetails({
|
|
122
|
-
data: {
|
|
123
|
-
description: item['Project Description'],
|
|
124
|
-
imageURL: '',
|
|
125
|
-
title: item.Name || 'Gitcoin GG-18',
|
|
126
|
-
links: [
|
|
127
|
-
{
|
|
128
|
-
type: 'website',
|
|
129
|
-
url: item.Website,
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
type: 'twitter',
|
|
133
|
-
url: item.Twitter,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
type: 'github',
|
|
137
|
-
url: item.Github,
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
slug: await gap.generateSlug(item.Name),
|
|
141
|
-
},
|
|
142
|
-
recipient: project.recipient,
|
|
143
|
-
schema: gap.findSchema('ProjectDetails'),
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const member = new MemberOf({
|
|
147
|
-
data: { memberOf: true },
|
|
148
|
-
recipient: project.recipient,
|
|
149
|
-
schema: gap.findSchema('MemberOf'),
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
project.members.push(member);
|
|
153
|
-
|
|
154
|
-
const grant = new Grant({
|
|
155
|
-
data: { communityUID },
|
|
156
|
-
recipient: project.recipient,
|
|
157
|
-
schema: gap.findSchema('Grant'),
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
grant.details = new GrantDetails({
|
|
161
|
-
data: {
|
|
162
|
-
proposalURL: item.URL,
|
|
163
|
-
title: item.Name,
|
|
164
|
-
description: item['Project Description'],
|
|
165
|
-
payoutAddress: project.recipient,
|
|
166
|
-
},
|
|
167
|
-
recipient: project.recipient,
|
|
168
|
-
schema: gap.findSchema('GrantDetails'),
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
grant.updates.push(
|
|
172
|
-
new GrantUpdate({
|
|
173
|
-
data: {
|
|
174
|
-
text: item['Grant Update'],
|
|
175
|
-
title: 'Initial Update',
|
|
176
|
-
type: 'grant-update',
|
|
177
|
-
},
|
|
178
|
-
recipient: project.recipient,
|
|
179
|
-
schema: gap.findSchema('GrantDetails'),
|
|
180
|
-
})
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
project.grants.push(grant);
|
|
184
|
-
await project.attest(wallet as any);
|
|
185
|
-
uids.push(project.uid);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
console.log('Attesting...');
|
|
189
|
-
console.log('Attested projects: ', uids.length);
|
|
190
|
-
console.log(uids);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
bootstrap();
|
package/docs/.gitkeep
DELETED
|
File without changes
|
|
Binary file
|
|
Binary file
|
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./core";
|
package/schemas/.gitkeep
DELETED
|
File without changes
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"type": 2,
|
|
4
|
-
"chainId": 11155111,
|
|
5
|
-
"nonce": 30,
|
|
6
|
-
"maxPriorityFeePerGas": {
|
|
7
|
-
"type": "BigNumber",
|
|
8
|
-
"hex": "0x59682f00"
|
|
9
|
-
},
|
|
10
|
-
"maxFeePerGas": {
|
|
11
|
-
"type": "BigNumber",
|
|
12
|
-
"hex": "0x70f1f3e4"
|
|
13
|
-
},
|
|
14
|
-
"gasPrice": null,
|
|
15
|
-
"gasLimit": {
|
|
16
|
-
"type": "BigNumber",
|
|
17
|
-
"hex": "0x4c4b40"
|
|
18
|
-
},
|
|
19
|
-
"to": "0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0",
|
|
20
|
-
"value": {
|
|
21
|
-
"type": "BigNumber",
|
|
22
|
-
"hex": "0x00"
|
|
23
|
-
},
|
|
24
|
-
"data": "0x60d7a278000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000c626f6f6c206772616e7465650000000000000000000000000000000000000000",
|
|
25
|
-
"accessList": [],
|
|
26
|
-
"hash": "0x0ac97981eefc8212d7e69a9cc035787195f90ebed1ebbd77d013b1baec943b73",
|
|
27
|
-
"v": 1,
|
|
28
|
-
"r": "0x19b4fbc082c1a8bd83ea660822a9d0a862791c905ca59ee4e49a016409df2436",
|
|
29
|
-
"s": "0x69c5955bbf676c31fd6b60fda6159a12db5bfcd3ad2acba40022869567a35f8b",
|
|
30
|
-
"from": "0x5A4830885f12438E00D8f4d98e9Fe083e707698C",
|
|
31
|
-
"confirmations": 0
|
|
32
|
-
}
|
|
33
|
-
]
|
package/test-file.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
|
-
import { Project, GAP, Grant, Hex, GapSchema } from "./core";
|
|
3
|
-
import { GapIndexerClient } from "./core/class";
|
|
4
|
-
import axios from "axios";
|
|
5
|
-
|
|
6
|
-
const key = require("./config/keys.json").sepolia;
|
|
7
|
-
|
|
8
|
-
const web3 = new ethers.providers.JsonRpcProvider(
|
|
9
|
-
"https://goerli.optimism.io"
|
|
10
|
-
// "https://eth-sepolia-public.unifra.io"
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const wallet = new ethers.Wallet(key, web3);
|
|
14
|
-
const gap = new GAP({
|
|
15
|
-
network: "optimism-goerli",
|
|
16
|
-
apiClient: new GapIndexerClient("http://localhost:3001"),
|
|
17
|
-
gelatoOpts: {
|
|
18
|
-
// env_gelatoApiKey: "GELATO_API_KEY",
|
|
19
|
-
// sponsorUrl: "http://localhost:3000/api/sponsored-txn",
|
|
20
|
-
apiKey: "{{apikey}}",
|
|
21
|
-
useGasless: true,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
console.time("fetchSchemas");
|
|
26
|
-
|
|
27
|
-
const grantDetails = (grants: Grant[] = []) =>
|
|
28
|
-
grants.map((g) => ({
|
|
29
|
-
uid: g.uid,
|
|
30
|
-
title: g.details?.title,
|
|
31
|
-
refUID: g.refUID,
|
|
32
|
-
milestones: g.milestones.map((m) => ({
|
|
33
|
-
uid: m.uid,
|
|
34
|
-
title: m.title,
|
|
35
|
-
description: m.description,
|
|
36
|
-
completed: { ...m.completed?.data },
|
|
37
|
-
approved: { ...m.approved?.data },
|
|
38
|
-
rejected: { ...m.rejected?.data },
|
|
39
|
-
})),
|
|
40
|
-
community: {
|
|
41
|
-
uid: g?.community?.uid,
|
|
42
|
-
name: g?.community?.details?.name,
|
|
43
|
-
},
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
const projectDetails = (projects: Project[] = []) =>
|
|
47
|
-
projects.map((p) => ({
|
|
48
|
-
uid: p.uid,
|
|
49
|
-
title: p.details?.title,
|
|
50
|
-
description: p.details?.description,
|
|
51
|
-
tags: p.details?.tags?.map((t) => t.name) || [],
|
|
52
|
-
imageURL: p.details?.imageURL,
|
|
53
|
-
members: p.members.map((m) => ({
|
|
54
|
-
uid: m.uid,
|
|
55
|
-
address: m.recipient,
|
|
56
|
-
name: m.details?.name,
|
|
57
|
-
profilePictureURL: m.details?.profilePictureURL,
|
|
58
|
-
})),
|
|
59
|
-
grants: grantDetails(p.grants),
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
async function attestation() {
|
|
63
|
-
const [projectSchema] = GapSchema.findMany(["Project", "ProjectDetails"], gap.network);
|
|
64
|
-
|
|
65
|
-
const project = new Project({
|
|
66
|
-
data: { project: true },
|
|
67
|
-
schema: projectSchema,
|
|
68
|
-
recipient: "0x5A4830885f12438E00D8f4d98e9Fe083e707698C",
|
|
69
|
-
// uid: "0x0f290f88ef6b3838f83b49bd0c1eeb4bda31502d0aa4591470fac30abb2f0111",
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await project.attest(wallet as any);
|
|
73
|
-
|
|
74
|
-
return [project.uid];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function getProject(uid: Hex) {
|
|
78
|
-
const project = await gap.fetch.projectById(uid);
|
|
79
|
-
|
|
80
|
-
// await project.grants[0].milestones[0].complete(wallet as any);
|
|
81
|
-
console.log(JSON.stringify(projectDetails([project]), null, 2));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
axios.get("http://localhost:3001/grants/0x73ddffeff8b14fbea412ac79ba7814eb0dec9bae84b12a91c2c3c91f6b3580c4").then(({data}) => {
|
|
86
|
-
Grant.from([data]);
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
// attestation().then((uids) => {
|
|
90
|
-
// console.log(uids);
|
|
91
|
-
// getProject(uids[0]);
|
|
92
|
-
// });
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": ["es2020"],
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"target": "es2020",
|
|
6
|
-
"outDir": "./.dist",
|
|
7
|
-
"baseUrl": ".",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"resolveJsonModule": true
|
|
12
|
-
},
|
|
13
|
-
"exclude": [
|
|
14
|
-
"**/.dist",
|
|
15
|
-
"**/config",
|
|
16
|
-
"**/config/*",
|
|
17
|
-
"**/scripts",
|
|
18
|
-
"**/scripts/*",
|
|
19
|
-
"node_modules",
|
|
20
|
-
"./node_modules",
|
|
21
|
-
"./node_modules/*",
|
|
22
|
-
"./node_modules/@types/node/index.d.ts"
|
|
23
|
-
],
|
|
24
|
-
"include": ["core/**/*.ts"],
|
|
25
|
-
"files": ["./index.ts"]
|
|
26
|
-
}
|