@show-karma/karma-gap-sdk 0.3.3 → 0.3.4
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/config/keys.example.json +6 -0
- package/core/abi/EAS.json +1 -0
- package/core/abi/SchemaRegistry.json +1 -0
- package/core/class/Attestation.ts +402 -0
- package/core/class/Fetcher.ts +202 -0
- package/core/class/GAP.d.ts +3 -1
- package/core/class/GAP.js +5 -2
- package/core/class/GAP.ts +398 -0
- package/core/class/GapSchema.ts +90 -0
- package/core/class/Gelato/Gelato.ts +286 -0
- package/core/class/GraphQL/AxiosGQL.ts +29 -0
- package/core/class/GraphQL/EASClient.ts +34 -0
- package/core/class/GraphQL/GapEasClient.ts +845 -0
- package/core/class/GraphQL/index.ts +3 -0
- package/core/class/Schema.ts +609 -0
- package/core/class/SchemaError.ts +36 -0
- package/core/class/contract/GapContract.js +2 -2
- package/core/class/contract/GapContract.ts +353 -0
- package/core/class/entities/Community.ts +115 -0
- package/core/class/entities/Grant.ts +309 -0
- package/core/class/entities/MemberOf.ts +42 -0
- package/core/class/entities/Milestone.ts +269 -0
- package/core/class/entities/Project.ts +370 -0
- package/core/class/entities/index.ts +5 -0
- package/core/class/index.ts +10 -0
- package/core/class/karma-indexer/GapIndexerClient.ts +245 -0
- package/core/class/remote-storage/IpfsStorage.ts +51 -0
- package/core/class/remote-storage/RemoteStorage.ts +65 -0
- package/core/class/types/attestations.ts +158 -0
- package/core/consts.ts +282 -0
- package/core/index.ts +7 -0
- package/core/scripts/deploy.ts +67 -0
- package/core/scripts/index.ts +1 -0
- package/core/types.ts +186 -0
- package/core/utils/gelato/index.ts +3 -0
- package/core/utils/gelato/send-gelato-txn.ts +114 -0
- package/core/utils/gelato/sponsor-handler.ts +77 -0
- package/core/utils/gelato/watch-gelato-txn.ts +67 -0
- package/core/utils/get-date.ts +3 -0
- package/core/utils/get-ipfs-data.ts +13 -0
- package/core/utils/get-web3-provider.ts +20 -0
- package/core/utils/gql-queries.ts +133 -0
- package/core/utils/index.ts +7 -0
- package/core/utils/map-filter.ts +21 -0
- package/core/utils/serialize-bigint.ts +7 -0
- package/core/utils/to-unix.ts +18 -0
- package/csv-upload/.gitkeep +0 -0
- package/csv-upload/example.csv +2 -0
- package/csv-upload/scripts/run.ts +193 -0
- 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 +1 -0
- package/package.json +1 -1
- package/readme.md +39 -34
- package/schemas/.gitkeep +0 -0
- package/schemas/GAP-schemas-1692135812877.json +33 -0
- package/test-file.ts +92 -0
- package/tsconfig.json +26 -0
- package/core/class/AttestationIPFS.d.ts +0 -7
- package/core/class/AttestationIPFS.js +0 -10
- package/core/class/GraphQL/Fetcher.d.ts +0 -132
- package/core/class/GraphQL/Fetcher.js +0 -7
- package/core/class/GraphQL/GAPFetcher.d.ts +0 -160
- package/core/class/GraphQL/GAPFetcher.js +0 -516
- package/core/class/IPFS/IPFS.d.ts +0 -13
- package/core/class/IPFS/IPFS.js +0 -24
- package/core/class/contract/MultiAttest.d.ts +0 -10
- package/core/class/contract/MultiAttest.js +0 -19
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { STORAGE_TYPE, TRemoteStorageOutput, TSchemaName } from 'core/types';
|
|
3
|
+
|
|
4
|
+
interface SponsoredRemote {
|
|
5
|
+
url: string;
|
|
6
|
+
responseParser: (response: any) => string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export abstract class RemoteStorage<C = unknown> {
|
|
10
|
+
protected client: C;
|
|
11
|
+
readonly storageType: number;
|
|
12
|
+
|
|
13
|
+
readonly sponsor?: SponsoredRemote;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
storageType: STORAGE_TYPE,
|
|
17
|
+
/**
|
|
18
|
+
* If set, will try to POST request to another server instead of
|
|
19
|
+
* using the local instance.
|
|
20
|
+
*
|
|
21
|
+
* > If a response parser is not set, it will try to get { cid: string }.
|
|
22
|
+
*/
|
|
23
|
+
sponsor: SponsoredRemote
|
|
24
|
+
) {
|
|
25
|
+
this.storageType = storageType;
|
|
26
|
+
this.sponsor = sponsor;
|
|
27
|
+
this.interceptRemoteStorage();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Try to save data to remote storage and return the CID.
|
|
32
|
+
* IF sponsorUrl is set, this method will be automatically
|
|
33
|
+
* intercepted and will send a POST request to the sponsorUrl
|
|
34
|
+
* with the contents: `{ data: T, type: "<AttestationType>" }`
|
|
35
|
+
*/
|
|
36
|
+
abstract save<T = unknown>(data: T, schemaName: string): Promise<string>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Encodes the data according to the remote storage type parameters
|
|
40
|
+
* OR returns the data as is if no encoding is required
|
|
41
|
+
*/
|
|
42
|
+
abstract encode(data: unknown): TRemoteStorageOutput;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get data from Remote Storage
|
|
46
|
+
*/
|
|
47
|
+
abstract get<T = unknown>(args: unknown): Promise<T>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* If sponsorUrl is set, intercept the save method and send a POST request
|
|
51
|
+
* to the sponsorUrl instead of using the local instance.
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
private interceptRemoteStorage() {
|
|
55
|
+
if (!this.sponsor?.url) return;
|
|
56
|
+
this.save = async (data: unknown, schemaName: TSchemaName) => {
|
|
57
|
+
const { data: response } = await axios.post(this.sponsor.url, {
|
|
58
|
+
data: data,
|
|
59
|
+
type: schemaName,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return this.sponsor.responseParser?.(response) || response.cid;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Attestation } from '../Attestation';
|
|
2
|
+
import { Hex, TExternalLink } from 'core/types';
|
|
3
|
+
import { Project } from '../entities/Project';
|
|
4
|
+
|
|
5
|
+
/** Attestation interfaces */
|
|
6
|
+
|
|
7
|
+
export type ExternalLink = { type: string; url: string }[];
|
|
8
|
+
|
|
9
|
+
export interface ICommunityDetails {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
imageURL: string;
|
|
13
|
+
slug?: string;
|
|
14
|
+
links?: ExternalLink;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class CommunityDetails
|
|
18
|
+
extends Attestation<ICommunityDetails>
|
|
19
|
+
implements ICommunityDetails
|
|
20
|
+
{
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
imageURL: string;
|
|
24
|
+
links: ExternalLink = [];
|
|
25
|
+
slug?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IGrantDetails {
|
|
29
|
+
title: string;
|
|
30
|
+
amount?: string;
|
|
31
|
+
proposalURL: string;
|
|
32
|
+
assetAndChainId?: [Hex, number];
|
|
33
|
+
payoutAddress?: Hex;
|
|
34
|
+
description?: string;
|
|
35
|
+
// communityUID: Hex;
|
|
36
|
+
season?: string;
|
|
37
|
+
cycle?: string;
|
|
38
|
+
questions?: IGrantDetailsQuestion[];
|
|
39
|
+
}
|
|
40
|
+
export class GrantDetails
|
|
41
|
+
extends Attestation<IGrantDetails>
|
|
42
|
+
implements IGrantDetails
|
|
43
|
+
{
|
|
44
|
+
title: string;
|
|
45
|
+
proposalURL: string;
|
|
46
|
+
// communityUID: Hex;
|
|
47
|
+
payoutAddress?: Hex;
|
|
48
|
+
amount?: string;
|
|
49
|
+
assetAndChainId?: [Hex, number];
|
|
50
|
+
description?: string;
|
|
51
|
+
season?: string;
|
|
52
|
+
cycle?: string;
|
|
53
|
+
questions?: IGrantDetailsQuestion[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IGrantRound {
|
|
57
|
+
name: string;
|
|
58
|
+
}
|
|
59
|
+
export class GrantRound
|
|
60
|
+
extends Attestation<IGrantRound>
|
|
61
|
+
implements IGrantRound
|
|
62
|
+
{
|
|
63
|
+
name: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface IGrantVerified {
|
|
67
|
+
verified: boolean;
|
|
68
|
+
}
|
|
69
|
+
export class GrantVerified
|
|
70
|
+
extends Attestation<IGrantVerified>
|
|
71
|
+
implements IGrantVerified
|
|
72
|
+
{
|
|
73
|
+
verified: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface IMemberDetails {
|
|
77
|
+
name: string;
|
|
78
|
+
profilePictureURL: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class MemberDetails
|
|
82
|
+
extends Attestation<IMemberDetails>
|
|
83
|
+
implements IMemberDetails
|
|
84
|
+
{
|
|
85
|
+
name: string;
|
|
86
|
+
profilePictureURL: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface IMilestoneCompleted {
|
|
90
|
+
type: 'approved' | 'rejected' | 'completed';
|
|
91
|
+
reason?: string;
|
|
92
|
+
}
|
|
93
|
+
export class MilestoneCompleted
|
|
94
|
+
extends Attestation<IMilestoneCompleted>
|
|
95
|
+
implements IMilestoneCompleted
|
|
96
|
+
{
|
|
97
|
+
type: 'approved' | 'rejected' | 'completed';
|
|
98
|
+
reason?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface ITag {
|
|
102
|
+
name: string;
|
|
103
|
+
}
|
|
104
|
+
export class Tag extends Attestation<ITag> implements ITag {
|
|
105
|
+
name: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface IProjectDetails {
|
|
109
|
+
title: string;
|
|
110
|
+
description: string;
|
|
111
|
+
imageURL: string;
|
|
112
|
+
links?: ExternalLink;
|
|
113
|
+
tags?: ITag[];
|
|
114
|
+
slug?: string;
|
|
115
|
+
}
|
|
116
|
+
export class ProjectDetails
|
|
117
|
+
extends Attestation<IProjectDetails>
|
|
118
|
+
implements IProjectDetails
|
|
119
|
+
{
|
|
120
|
+
title: string;
|
|
121
|
+
description: string;
|
|
122
|
+
imageURL: string;
|
|
123
|
+
links: ExternalLink = [];
|
|
124
|
+
tags: ITag[] = [];
|
|
125
|
+
slug: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export class Grantee {
|
|
129
|
+
address: string;
|
|
130
|
+
projects: Project[] = [];
|
|
131
|
+
|
|
132
|
+
constructor(address: Hex, projects: Project[] = []) {
|
|
133
|
+
this.address = address;
|
|
134
|
+
this.projects = projects;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface IGrantUpdate {
|
|
139
|
+
title: string;
|
|
140
|
+
text: string;
|
|
141
|
+
type?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export class GrantUpdate
|
|
145
|
+
extends Attestation<IGrantUpdate>
|
|
146
|
+
implements IGrantUpdate
|
|
147
|
+
{
|
|
148
|
+
title: string;
|
|
149
|
+
text: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export class GrantCompleted extends GrantUpdate {}
|
|
153
|
+
|
|
154
|
+
export interface IGrantDetailsQuestion {
|
|
155
|
+
query: string,
|
|
156
|
+
explanation: string,
|
|
157
|
+
type: string
|
|
158
|
+
}
|
package/core/consts.ts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EASNetworkConfig,
|
|
3
|
+
SchemaInterface,
|
|
4
|
+
TNetwork,
|
|
5
|
+
TSchemaName,
|
|
6
|
+
} from './types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Schemas that should use default EAS attestation
|
|
10
|
+
* instead of the custom contract.
|
|
11
|
+
*/
|
|
12
|
+
export const useDefaultAttestation: TSchemaName[] = [
|
|
13
|
+
'MilestoneApproved',
|
|
14
|
+
'MilestoneCompleted',
|
|
15
|
+
'GrantVerified',
|
|
16
|
+
'Community',
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const nullRef =
|
|
20
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
21
|
+
|
|
22
|
+
// TODO: Remove null resolver and change usage to zero address
|
|
23
|
+
export const nullResolver = '0x0000000000000000000000000000000000000000';
|
|
24
|
+
|
|
25
|
+
export const zeroAddress = nullResolver;
|
|
26
|
+
// resolver for dependents = 0xed081ABE885bc3575f810c904052A1f685A85903
|
|
27
|
+
/**
|
|
28
|
+
* The networks that are supported by the EAS
|
|
29
|
+
*/
|
|
30
|
+
export const Networks: Record<TNetwork, EASNetworkConfig> = {
|
|
31
|
+
// mainnet: {
|
|
32
|
+
// url: "https://easscan.org/graphql",
|
|
33
|
+
// chainId: 1,
|
|
34
|
+
// contracts: {
|
|
35
|
+
// eas: "0xA1207F3BBa224E2c9c3c6D5aF63D0eb1582Ce587",
|
|
36
|
+
// schema: "0xA7b39296258348C78294F95B872b282326A97BDF",
|
|
37
|
+
// multicall:''
|
|
38
|
+
// },
|
|
39
|
+
// schemas: {
|
|
40
|
+
// Grant: "",
|
|
41
|
+
// GrantVerified: "",
|
|
42
|
+
// MemberOf: "",
|
|
43
|
+
// MilestoneApproved: "",
|
|
44
|
+
// MilestoneCompleted: "",
|
|
45
|
+
// Project: "",
|
|
46
|
+
// },
|
|
47
|
+
// },
|
|
48
|
+
// "base-goerli": {
|
|
49
|
+
// chainId: 5,
|
|
50
|
+
// url: "https://base-goerli.easscan.org/graphql",
|
|
51
|
+
// contracts: {
|
|
52
|
+
// eas: "0xAcfE09Fd03f7812F022FBf636700AdEA18Fd2A7A",
|
|
53
|
+
// schema: "0x720c2bA66D19A725143FBf5fDC5b4ADA2742682E",
|
|
54
|
+
// multicall:''
|
|
55
|
+
// },
|
|
56
|
+
// schemas: {
|
|
57
|
+
// Grant: "",
|
|
58
|
+
// GrantVerified: "",
|
|
59
|
+
// MemberOf: "",
|
|
60
|
+
// MilestoneApproved: "",
|
|
61
|
+
// MilestoneCompleted: "",
|
|
62
|
+
// Project: "",
|
|
63
|
+
// },
|
|
64
|
+
// },
|
|
65
|
+
optimism: {
|
|
66
|
+
chainId: 10,
|
|
67
|
+
url: 'https://optimism.easscan.org/graphql',
|
|
68
|
+
rpcUrl:
|
|
69
|
+
'https://opt-mainnet.g.alchemy.com/v2/fx2SlVDrPbXwPMQT4v0lRT1PABA16Myl',
|
|
70
|
+
contracts: {
|
|
71
|
+
eas: '0x4200000000000000000000000000000000000021',
|
|
72
|
+
schema: '0x4200000000000000000000000000000000000020',
|
|
73
|
+
multicall: '0xd2eD366393FDfd243931Fe48e9fb65A192B0018c', //proxy,
|
|
74
|
+
projectResolver: '0x7177AdC0f924b695C0294A40C4C5FEFf5EE1E141',
|
|
75
|
+
},
|
|
76
|
+
schemas: {
|
|
77
|
+
Community:
|
|
78
|
+
'0x721c17b065dccc5c916e0c2708d0ef50f1810591b76d0402ff6fe5accbd8488f',
|
|
79
|
+
Details:
|
|
80
|
+
'0x70a3f615f738fc6a4f56100692ada93d947c028b840940d97af7e7d6f0fa0577',
|
|
81
|
+
Grant:
|
|
82
|
+
'0x12837231f48acbca4e1e7f4416f684f3353bd4d71d4f03a09d29e5ffa6f21a50',
|
|
83
|
+
GrantVerified:
|
|
84
|
+
'0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93',
|
|
85
|
+
MemberOf:
|
|
86
|
+
'0x7fbb8a65924d8ad2ae12356e04b1418043e8361ba3b1b6c917de2e23df3ec81c',
|
|
87
|
+
MilestoneApproved:
|
|
88
|
+
'0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93',
|
|
89
|
+
MilestoneCompleted:
|
|
90
|
+
'0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93',
|
|
91
|
+
Project:
|
|
92
|
+
'0x5b873b6e7a16207b526dde366e8164e95bcda2f009272306519667c5e94d2191',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
'optimism-goerli': {
|
|
96
|
+
chainId: 420,
|
|
97
|
+
url: 'https://optimism-goerli-bedrock.easscan.org/graphql',
|
|
98
|
+
rpcUrl:
|
|
99
|
+
'https://opt-goerli.g.alchemy.com/v2/94gBUTVw7SbDxxdeB8gi3KQmgQSD7SHi',
|
|
100
|
+
contracts: {
|
|
101
|
+
eas: '0x4200000000000000000000000000000000000021',
|
|
102
|
+
schema: '0x4200000000000000000000000000000000000020',
|
|
103
|
+
multicall: '0x5D5a8032b2FA06652804c33F60DcEA00e389B732', //proxy,
|
|
104
|
+
projectResolver: '0xbCf8910Bc3971eA59D93256357b76E846CF2e1F8',
|
|
105
|
+
},
|
|
106
|
+
schemas: {
|
|
107
|
+
Community:
|
|
108
|
+
'0xc1aade58410b3fd807c19845181996721248459c5f042284f27d21cec12a38d1', // new resolver
|
|
109
|
+
// "0x14b016a56b56db47ee2cdda6963a3481374a75e1471dafd85a17e6e5c23d2a11",
|
|
110
|
+
Details:
|
|
111
|
+
'0xfe590d9582957e10affbabcdc34a201785a1d4f77982d6616b736cce1a91ae43',
|
|
112
|
+
Grant:
|
|
113
|
+
'0xd6ce374765c355687101ba70b3f8824d555c12716d2bdad71a08ccad1ded3218',
|
|
114
|
+
GrantVerified:
|
|
115
|
+
'0xf544fbd9721ac50863d32dc0eed5992051e7fb270b38ab2ce062327cc0ae26ea',
|
|
116
|
+
MemberOf:
|
|
117
|
+
'0x78c811e506849d414a91a56dab91f07f7ed108f0bf27f550796f13e7bb2e2f2d',
|
|
118
|
+
MilestoneApproved:
|
|
119
|
+
'0xf544fbd9721ac50863d32dc0eed5992051e7fb270b38ab2ce062327cc0ae26ea',
|
|
120
|
+
MilestoneCompleted:
|
|
121
|
+
'0xf544fbd9721ac50863d32dc0eed5992051e7fb270b38ab2ce062327cc0ae26ea',
|
|
122
|
+
Project:
|
|
123
|
+
'0xa727441596f5a9878552d3ad6c53c31629a709451e6081ba01bff0f73bf1af5a',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
arbitrum: {
|
|
127
|
+
chainId: 42161,
|
|
128
|
+
url: 'https://arbitrum.easscan.org/graphql',
|
|
129
|
+
rpcUrl: 'https://arb-mainnet.g.alchemy.com/v2/okcKBSKXvLuSCbas6QWGvKuh-IcHHSOr',
|
|
130
|
+
contracts: {
|
|
131
|
+
eas: '0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458',
|
|
132
|
+
schema: '0xA310da9c5B885E7fb3fbA9D66E9Ba6Df512b78eB',
|
|
133
|
+
multicall: '0x6dC1D6b864e8BEf815806f9e4677123496e12026', //proxy,
|
|
134
|
+
projectResolver: '0x28BE0b0515be8BB8822aF1467A6613795E74717b',
|
|
135
|
+
},
|
|
136
|
+
schemas: {
|
|
137
|
+
Community:
|
|
138
|
+
'0xc604f0661cfd522583835ed2b2c644b80e068139d287f93c7f1680888894bacc',
|
|
139
|
+
Details:
|
|
140
|
+
'0x16bfe4783b7a9c743c401222c56a07ecb77ed42afc84b61ff1f62f5936c0b9d7',
|
|
141
|
+
Grant:
|
|
142
|
+
'0xea02ab33f9f4c92ba02c9bb21614b7410b98c940a0d8eb8ad3a20204d8b4bda5',
|
|
143
|
+
GrantVerified:
|
|
144
|
+
'0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15',
|
|
145
|
+
MemberOf:
|
|
146
|
+
'0x5f430aec9d04f0dcb3729775c5dfe10752e436469a7607f8c64ae44ef996e477',
|
|
147
|
+
MilestoneApproved:
|
|
148
|
+
'0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15',
|
|
149
|
+
MilestoneCompleted:
|
|
150
|
+
'0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15',
|
|
151
|
+
Project:
|
|
152
|
+
'0xac2a06e955a7e25e6729efe1a6532237e3435b21ccd3dc827ae3c94e624d25b3',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
sepolia: {
|
|
156
|
+
chainId: 11155111,
|
|
157
|
+
url: 'https://sepolia.easscan.org/graphql',
|
|
158
|
+
rpcUrl: 'https://rpc.sepolia.io',
|
|
159
|
+
contracts: {
|
|
160
|
+
eas: '0xC2679fBD37d54388Ce493F1DB75320D236e1815e',
|
|
161
|
+
schema: '0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0',
|
|
162
|
+
multicall: '0xec8d7BFe344790FD860920C41B46B259c005727A',
|
|
163
|
+
projectResolver: '0x099787D5a5aC92779A519CfD925ACB0Dc7E8bd23',
|
|
164
|
+
},
|
|
165
|
+
schemas: {
|
|
166
|
+
Community:
|
|
167
|
+
'0xf3d790c7fdab6c1b1f25ffcc9289e5be2792eb596d2851a4d059c8aae1bc8b2e', //test with resolver
|
|
168
|
+
// "0x1954572e3fe21bf4334afdaf1358ed7098af1ed136e76dc93c2fdc25e83934c1", // original without resolver
|
|
169
|
+
Details:
|
|
170
|
+
'0x2c270e35bfcdc4d611f0e9d3d2ab6924ec6c673505abc22a1dd07e19b67211af',
|
|
171
|
+
Grant:
|
|
172
|
+
'0x09697aeeb3ae71de1cc19e388fd74264f11af5fba3016094764553ac341fdc72', // with communityUID/resolver
|
|
173
|
+
GrantVerified:
|
|
174
|
+
'0x0be8952e2dd74ffd63a02f4d55b20b603fe7a60130cb9d70de31feb9c52fdd37',
|
|
175
|
+
MemberOf:
|
|
176
|
+
'0xdd87b3500457931252424f4439365534ba72a367503a8805ff3482353fb90301',
|
|
177
|
+
MilestoneApproved:
|
|
178
|
+
'0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322',
|
|
179
|
+
MilestoneCompleted:
|
|
180
|
+
'0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322',
|
|
181
|
+
Project:
|
|
182
|
+
'0xec77990a252b54b17673955c774b9712766de5eecb22ca5aa2c440e0e93257fb',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
} as const;
|
|
186
|
+
|
|
187
|
+
const DetailsSchema = [{ type: 'string', name: 'json', value: null }];
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Mounts the schemas for the given network and return all the settings
|
|
191
|
+
* @param network
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
export const MountEntities = (
|
|
195
|
+
network: EASNetworkConfig
|
|
196
|
+
): Record<TSchemaName, SchemaInterface<TSchemaName>> => ({
|
|
197
|
+
Community: {
|
|
198
|
+
name: 'Community',
|
|
199
|
+
schema: [{ type: 'bool', name: 'community', value: true }],
|
|
200
|
+
uid: network.schemas.Community,
|
|
201
|
+
},
|
|
202
|
+
CommunityDetails: {
|
|
203
|
+
name: 'CommunityDetails',
|
|
204
|
+
schema: DetailsSchema,
|
|
205
|
+
uid: network.schemas.Details,
|
|
206
|
+
references: 'Community',
|
|
207
|
+
},
|
|
208
|
+
Project: {
|
|
209
|
+
name: 'Project',
|
|
210
|
+
schema: [{ type: 'bool', name: 'project', value: true }],
|
|
211
|
+
uid: network.schemas.Project,
|
|
212
|
+
},
|
|
213
|
+
ProjectDetails: {
|
|
214
|
+
name: 'ProjectDetails',
|
|
215
|
+
schema: DetailsSchema,
|
|
216
|
+
uid: network.schemas.Details,
|
|
217
|
+
references: 'Project',
|
|
218
|
+
},
|
|
219
|
+
MemberOf: {
|
|
220
|
+
name: 'MemberOf',
|
|
221
|
+
schema: [{ type: 'bool', name: 'memberOf', value: true }],
|
|
222
|
+
uid: network.schemas.MemberOf,
|
|
223
|
+
references: 'Project',
|
|
224
|
+
},
|
|
225
|
+
MemberDetails: {
|
|
226
|
+
name: 'MemberDetails',
|
|
227
|
+
schema: DetailsSchema,
|
|
228
|
+
uid: network.schemas.Details,
|
|
229
|
+
references: 'MemberOf',
|
|
230
|
+
},
|
|
231
|
+
Grant: {
|
|
232
|
+
name: 'Grant',
|
|
233
|
+
schema: [{ type: 'bytes32', name: 'communityUID', value: true }],
|
|
234
|
+
// schema: [{ type: "bool", name: "grant", value: true }],
|
|
235
|
+
uid: network.schemas.Grant,
|
|
236
|
+
references: 'Project',
|
|
237
|
+
},
|
|
238
|
+
GrantDetails: {
|
|
239
|
+
name: 'GrantDetails',
|
|
240
|
+
schema: DetailsSchema,
|
|
241
|
+
uid: network.schemas.Details,
|
|
242
|
+
references: 'Grant',
|
|
243
|
+
},
|
|
244
|
+
GrantVerified: {
|
|
245
|
+
name: 'GrantVerified',
|
|
246
|
+
schema: [
|
|
247
|
+
{ type: 'string', name: 'type', value: null },
|
|
248
|
+
{ type: 'string', name: 'reason', value: '' },
|
|
249
|
+
],
|
|
250
|
+
uid: network.schemas.GrantVerified,
|
|
251
|
+
references: 'Grant',
|
|
252
|
+
},
|
|
253
|
+
Milestone: {
|
|
254
|
+
name: 'Milestone',
|
|
255
|
+
schema: DetailsSchema,
|
|
256
|
+
uid: network.schemas.Details,
|
|
257
|
+
references: 'Grant',
|
|
258
|
+
},
|
|
259
|
+
MilestoneApproved: {
|
|
260
|
+
name: 'MilestoneApproved',
|
|
261
|
+
schema: [
|
|
262
|
+
{ type: 'string', name: 'type', value: null },
|
|
263
|
+
{ type: 'string', name: 'reason', value: '' },
|
|
264
|
+
],
|
|
265
|
+
uid: network.schemas.MilestoneApproved,
|
|
266
|
+
references: 'Milestone',
|
|
267
|
+
},
|
|
268
|
+
MilestoneCompleted: {
|
|
269
|
+
name: 'MilestoneCompleted',
|
|
270
|
+
schema: [
|
|
271
|
+
{ type: 'string', name: 'type', value: null },
|
|
272
|
+
{ type: 'string', name: 'reason', value: '' },
|
|
273
|
+
],
|
|
274
|
+
uid: network.schemas.MilestoneCompleted,
|
|
275
|
+
references: 'Milestone',
|
|
276
|
+
},
|
|
277
|
+
Details: {
|
|
278
|
+
schema: DetailsSchema,
|
|
279
|
+
name: ' schema',
|
|
280
|
+
uid: network.schemas.Details,
|
|
281
|
+
},
|
|
282
|
+
});
|
package/core/index.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { EASNetworkConfig, TNetwork } from '../types';
|
|
2
|
+
import { MountEntities, Networks, zeroAddress } from '../consts';
|
|
3
|
+
|
|
4
|
+
import SchemaRegistry from '../abi/SchemaRegistry.json';
|
|
5
|
+
|
|
6
|
+
import { ethers } from 'ethers';
|
|
7
|
+
|
|
8
|
+
import keys from '../../config/keys.json';
|
|
9
|
+
import { GapSchema } from '../class/GapSchema';
|
|
10
|
+
import { writeFileSync } from 'fs';
|
|
11
|
+
|
|
12
|
+
const web3 = new ethers.providers.JsonRpcProvider(
|
|
13
|
+
'https://eth-sepolia-public.unifra.io'
|
|
14
|
+
);
|
|
15
|
+
const wallet = new ethers.Wallet(keys.privateKey, web3);
|
|
16
|
+
|
|
17
|
+
const contract = new ethers.Contract(
|
|
18
|
+
Networks.sepolia.contracts.schema,
|
|
19
|
+
SchemaRegistry.abi,
|
|
20
|
+
wallet
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
async function deploy(networkName?: TNetwork) {
|
|
24
|
+
const [, , $3] = process.argv;
|
|
25
|
+
const network = Networks[networkName || $3] as EASNetworkConfig;
|
|
26
|
+
const key = keys[networkName || $3];
|
|
27
|
+
|
|
28
|
+
if (!(networkName || $3)) throw new Error('Network name is required');
|
|
29
|
+
if (!network) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Invalid network name. Supported networks are: ${Object.keys(
|
|
32
|
+
Networks
|
|
33
|
+
).join(', ')}`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!key) throw new Error('No keys found for this network');
|
|
37
|
+
|
|
38
|
+
const revocable = true;
|
|
39
|
+
|
|
40
|
+
const promises = Object.values(MountEntities(Networks.sepolia))
|
|
41
|
+
.slice(0, 1)
|
|
42
|
+
.map((entity) => {
|
|
43
|
+
return contract.functions.register(
|
|
44
|
+
new GapSchema(entity, {} as any).raw,
|
|
45
|
+
zeroAddress,
|
|
46
|
+
revocable,
|
|
47
|
+
{
|
|
48
|
+
gasLimit: 5000000n,
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
const results: any[] = [];
|
|
53
|
+
for (const tx of promises) {
|
|
54
|
+
const txn = await tx;
|
|
55
|
+
const result = await txn.wait();
|
|
56
|
+
results.push(result);
|
|
57
|
+
}
|
|
58
|
+
console.log(results);
|
|
59
|
+
writeFileSync(
|
|
60
|
+
`schemas/GAP-schemas-${Date.now()}.json`,
|
|
61
|
+
JSON.stringify(results, null, 2)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (process.argv[1].includes('core/scripts/deploy.ts')) deploy();
|
|
66
|
+
|
|
67
|
+
export { deploy };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './deploy';
|