@grapenpm/gpass-sdk 0.1.0
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/README.md +251 -0
- package/dist/index.d.mts +1041 -0
- package/dist/index.d.ts +1041 -0
- package/dist/index.js +3609 -0
- package/dist/index.mjs +3592 -0
- package/package.json +50 -0
- package/src/bn-js.d.ts +18 -0
- package/src/client.ts +349 -0
- package/src/idl.ts +531 -0
- package/src/index.ts +44 -0
- package/src/pda.ts +125 -0
- package/src/types/index.ts +294 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
|
|
4
|
+
// ─────────────────────────────────────────────────────────
|
|
5
|
+
// PROGRAM CONSTANTS
|
|
6
|
+
// ─────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
export const GPASS_PROGRAM_ID = new PublicKey(
|
|
9
|
+
"GPASSzQQF1H8cdj5pUwFkeYEE4VdMQtCrYtUaMXvPz48"
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const VINE_REPUTATION_PROGRAM_ID = new PublicKey(
|
|
13
|
+
"V1NE6WCWJPRiVFq5DtaN8p87M9DmmUd2zQuVbvLgQwX"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const GRAPE_VERIFICATION_PROGRAM_ID = new PublicKey(
|
|
17
|
+
"VrFyyRxPoyWxpABpBXU4YUCCF9p8giDSJUv2oXfDr5q"
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// Platform discriminants matching the on-chain enum
|
|
21
|
+
export enum VerificationPlatform {
|
|
22
|
+
Discord = 0,
|
|
23
|
+
Telegram = 1,
|
|
24
|
+
Twitter = 2,
|
|
25
|
+
Email = 3,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ─────────────────────────────────────────────────────────
|
|
29
|
+
// GATE TYPE
|
|
30
|
+
// ─────────────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
export type GateType =
|
|
33
|
+
| { singleUse: Record<string, never> }
|
|
34
|
+
| { reusable: Record<string, never> }
|
|
35
|
+
| { timeLimited: { durationSeconds: BN } }
|
|
36
|
+
| { subscription: { intervalSeconds: BN } };
|
|
37
|
+
|
|
38
|
+
export const GateTypeFactory = {
|
|
39
|
+
singleUse: (): GateType => ({ singleUse: {} }),
|
|
40
|
+
reusable: (): GateType => ({ reusable: {} }),
|
|
41
|
+
timeLimited: (durationSeconds: number): GateType => ({
|
|
42
|
+
timeLimited: { durationSeconds: new BN(durationSeconds) },
|
|
43
|
+
}),
|
|
44
|
+
subscription: (intervalSeconds: number): GateType => ({
|
|
45
|
+
subscription: { intervalSeconds: new BN(intervalSeconds) },
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// ─────────────────────────────────────────────────────────
|
|
50
|
+
// GATE CRITERIA
|
|
51
|
+
// ─────────────────────────────────────────────────────────
|
|
52
|
+
|
|
53
|
+
export type GateCriteria =
|
|
54
|
+
| {
|
|
55
|
+
minReputation: {
|
|
56
|
+
vineConfig: PublicKey;
|
|
57
|
+
minPoints: BN;
|
|
58
|
+
season: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
verifiedIdentity: {
|
|
63
|
+
grapeSpace: PublicKey;
|
|
64
|
+
platforms: Buffer;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
verifiedWithWallet: {
|
|
69
|
+
grapeSpace: PublicKey;
|
|
70
|
+
platforms: Buffer;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
combined: {
|
|
75
|
+
vineConfig: PublicKey;
|
|
76
|
+
minPoints: BN;
|
|
77
|
+
season: number;
|
|
78
|
+
grapeSpace: PublicKey;
|
|
79
|
+
platforms: Buffer;
|
|
80
|
+
requireWalletLink: boolean;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
| {
|
|
84
|
+
timeLockedReputation: {
|
|
85
|
+
vineConfig: PublicKey;
|
|
86
|
+
minPoints: BN;
|
|
87
|
+
season: number;
|
|
88
|
+
minHoldDurationSeconds: BN;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
| {
|
|
92
|
+
multiDao: {
|
|
93
|
+
requiredGates: PublicKey[];
|
|
94
|
+
requireAll: boolean;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
| {
|
|
98
|
+
tokenHolding: {
|
|
99
|
+
mint: PublicKey;
|
|
100
|
+
minAmount: BN;
|
|
101
|
+
checkAta: boolean;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
| {
|
|
105
|
+
nftCollection: {
|
|
106
|
+
collectionMint: PublicKey;
|
|
107
|
+
minCount: number;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
| {
|
|
111
|
+
customProgram: {
|
|
112
|
+
programId: PublicKey;
|
|
113
|
+
instructionData: Buffer;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Fluent factory for building criteria
|
|
118
|
+
export const GateCriteriaFactory = {
|
|
119
|
+
minReputation: (params: {
|
|
120
|
+
vineConfig: PublicKey;
|
|
121
|
+
minPoints: number | BN;
|
|
122
|
+
season: number;
|
|
123
|
+
}): GateCriteria => ({
|
|
124
|
+
minReputation: {
|
|
125
|
+
vineConfig: params.vineConfig,
|
|
126
|
+
minPoints: new BN(params.minPoints),
|
|
127
|
+
season: params.season,
|
|
128
|
+
},
|
|
129
|
+
}),
|
|
130
|
+
|
|
131
|
+
verifiedIdentity: (params: {
|
|
132
|
+
grapeSpace: PublicKey;
|
|
133
|
+
platforms: VerificationPlatform[];
|
|
134
|
+
}): GateCriteria => ({
|
|
135
|
+
verifiedIdentity: {
|
|
136
|
+
grapeSpace: params.grapeSpace,
|
|
137
|
+
platforms: Buffer.from(params.platforms),
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
|
|
141
|
+
verifiedWithWallet: (params: {
|
|
142
|
+
grapeSpace: PublicKey;
|
|
143
|
+
platforms: VerificationPlatform[];
|
|
144
|
+
}): GateCriteria => ({
|
|
145
|
+
verifiedWithWallet: {
|
|
146
|
+
grapeSpace: params.grapeSpace,
|
|
147
|
+
platforms: Buffer.from(params.platforms),
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
|
|
151
|
+
combined: (params: {
|
|
152
|
+
vineConfig: PublicKey;
|
|
153
|
+
minPoints: number | BN;
|
|
154
|
+
season: number;
|
|
155
|
+
grapeSpace: PublicKey;
|
|
156
|
+
platforms: VerificationPlatform[];
|
|
157
|
+
requireWalletLink?: boolean;
|
|
158
|
+
}): GateCriteria => ({
|
|
159
|
+
combined: {
|
|
160
|
+
vineConfig: params.vineConfig,
|
|
161
|
+
minPoints: new BN(params.minPoints),
|
|
162
|
+
season: params.season,
|
|
163
|
+
grapeSpace: params.grapeSpace,
|
|
164
|
+
platforms: Buffer.from(params.platforms),
|
|
165
|
+
requireWalletLink: params.requireWalletLink ?? false,
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
|
|
169
|
+
timeLockedReputation: (params: {
|
|
170
|
+
vineConfig: PublicKey;
|
|
171
|
+
minPoints: number | BN;
|
|
172
|
+
season: number;
|
|
173
|
+
minHoldDurationSeconds: number | BN;
|
|
174
|
+
}): GateCriteria => ({
|
|
175
|
+
timeLockedReputation: {
|
|
176
|
+
vineConfig: params.vineConfig,
|
|
177
|
+
minPoints: new BN(params.minPoints),
|
|
178
|
+
season: params.season,
|
|
179
|
+
minHoldDurationSeconds: new BN(params.minHoldDurationSeconds),
|
|
180
|
+
},
|
|
181
|
+
}),
|
|
182
|
+
|
|
183
|
+
multiDao: (params: {
|
|
184
|
+
requiredGates: PublicKey[];
|
|
185
|
+
requireAll?: boolean;
|
|
186
|
+
}): GateCriteria => ({
|
|
187
|
+
multiDao: {
|
|
188
|
+
requiredGates: params.requiredGates,
|
|
189
|
+
requireAll: params.requireAll ?? true,
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
|
|
193
|
+
tokenHolding: (params: {
|
|
194
|
+
mint: PublicKey;
|
|
195
|
+
minAmount: number | BN;
|
|
196
|
+
checkAta?: boolean;
|
|
197
|
+
}): GateCriteria => ({
|
|
198
|
+
tokenHolding: {
|
|
199
|
+
mint: params.mint,
|
|
200
|
+
minAmount: new BN(params.minAmount),
|
|
201
|
+
checkAta: params.checkAta ?? true,
|
|
202
|
+
},
|
|
203
|
+
}),
|
|
204
|
+
|
|
205
|
+
nftCollection: (params: {
|
|
206
|
+
collectionMint: PublicKey;
|
|
207
|
+
minCount?: number;
|
|
208
|
+
}): GateCriteria => ({
|
|
209
|
+
nftCollection: {
|
|
210
|
+
collectionMint: params.collectionMint,
|
|
211
|
+
minCount: params.minCount ?? 1,
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
|
|
215
|
+
customProgram: (params: {
|
|
216
|
+
programId: PublicKey;
|
|
217
|
+
instructionData?: Buffer;
|
|
218
|
+
}): GateCriteria => ({
|
|
219
|
+
customProgram: {
|
|
220
|
+
programId: params.programId,
|
|
221
|
+
instructionData: params.instructionData ?? Buffer.alloc(0),
|
|
222
|
+
},
|
|
223
|
+
}),
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// ─────────────────────────────────────────────────────────
|
|
227
|
+
// ACCOUNT TYPES
|
|
228
|
+
// ─────────────────────────────────────────────────────────
|
|
229
|
+
|
|
230
|
+
export interface Gate {
|
|
231
|
+
version: number;
|
|
232
|
+
gateId: PublicKey;
|
|
233
|
+
authority: PublicKey;
|
|
234
|
+
criteria: GateCriteria;
|
|
235
|
+
gateType: GateType;
|
|
236
|
+
isActive: boolean;
|
|
237
|
+
createdAt: BN;
|
|
238
|
+
totalChecks: BN;
|
|
239
|
+
successfulChecks: BN;
|
|
240
|
+
bump: number;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface GateCheckRecord {
|
|
244
|
+
version: number;
|
|
245
|
+
gate: PublicKey;
|
|
246
|
+
user: PublicKey;
|
|
247
|
+
passed: boolean;
|
|
248
|
+
checkedAt: BN;
|
|
249
|
+
bump: number;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ─────────────────────────────────────────────────────────
|
|
253
|
+
// SDK OPTIONS / PARAMS
|
|
254
|
+
// ─────────────────────────────────────────────────────────
|
|
255
|
+
|
|
256
|
+
export interface InitializeGateParams {
|
|
257
|
+
/** Unique identifier for this gate (use a fresh Keypair.publicKey) */
|
|
258
|
+
gateId: PublicKey;
|
|
259
|
+
criteria: GateCriteria;
|
|
260
|
+
gateType: GateType;
|
|
261
|
+
/** Defaults to the provider wallet */
|
|
262
|
+
authority?: PublicKey;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface CheckGateParams {
|
|
266
|
+
gateId: PublicKey;
|
|
267
|
+
user: PublicKey;
|
|
268
|
+
/** Vine reputation PDA — required for reputation-based criteria */
|
|
269
|
+
reputationAccount?: PublicKey;
|
|
270
|
+
/** Grape identity PDA — required for verification-based criteria */
|
|
271
|
+
identityAccount?: PublicKey;
|
|
272
|
+
/** Grape link PDA — required for VerifiedWithWallet / Combined */
|
|
273
|
+
linkAccount?: PublicKey;
|
|
274
|
+
/** SPL token account — required for TokenHolding criteria */
|
|
275
|
+
tokenAccount?: PublicKey;
|
|
276
|
+
/** If true, creates/updates a GateCheckRecord PDA on-chain */
|
|
277
|
+
storeRecord?: boolean;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface UpdateGateCriteriaParams {
|
|
281
|
+
gateId: PublicKey;
|
|
282
|
+
newCriteria: GateCriteria;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface SetGateActiveParams {
|
|
286
|
+
gateId: PublicKey;
|
|
287
|
+
isActive: boolean;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface CloseGateParams {
|
|
291
|
+
gateId: PublicKey;
|
|
292
|
+
/** SOL recipient — defaults to provider wallet */
|
|
293
|
+
recipient?: PublicKey;
|
|
294
|
+
}
|