@grapenpm/gpass-sdk 0.1.0 → 0.1.2
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 +63 -4
- package/dist/index.d.mts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +221 -187
- package/dist/index.mjs +221 -187
- package/package.json +3 -5
- package/src/client.ts +44 -20
- package/src/index.ts +1 -1
- package/src/types/index.ts +39 -6
- package/src/bn-js.d.ts +0 -18
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @grapenpm/gpass-sdk
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for the **Grape Gating Protocol** — composable access control for Solana DAOs.
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ TypeScript SDK for the **Grape Gating Protocol** — composable access control f
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install @
|
|
12
|
+
npm install @grapenpm/gpass-sdk
|
|
13
13
|
# peer deps
|
|
14
14
|
npm install @coral-xyz/anchor @solana/web3.js
|
|
15
15
|
```
|
|
@@ -19,7 +19,7 @@ npm install @coral-xyz/anchor @solana/web3.js
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
import { GpassClient, GateCriteriaFactory, GateTypeFactory, VerificationPlatform } from "@
|
|
22
|
+
import { GpassClient, GateCriteriaFactory, GateTypeFactory, VerificationPlatform } from "@grapenpm/gpass-sdk";
|
|
23
23
|
import { AnchorProvider } from "@coral-xyz/anchor";
|
|
24
24
|
import { Keypair } from "@solana/web3.js";
|
|
25
25
|
|
|
@@ -62,10 +62,24 @@ const passes = await client.simulateCheckGate({
|
|
|
62
62
|
console.log("User passes gate:", passes);
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
If you initialize with an authority different from the provider wallet, pass `authoritySigner`:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
await client.initializeGate({
|
|
69
|
+
gateId,
|
|
70
|
+
criteria,
|
|
71
|
+
gateType,
|
|
72
|
+
authority: externalAuthority.publicKey,
|
|
73
|
+
authoritySigner: externalAuthority,
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
65
77
|
---
|
|
66
78
|
|
|
67
79
|
## Gate Criteria
|
|
68
80
|
|
|
81
|
+
For criteria that rely on `remaining_accounts` on-chain (`MultiDao`, `NftCollection`, `CustomProgram`), pass those accounts with `checkGate({ remainingAccounts: [...] })`.
|
|
82
|
+
|
|
69
83
|
### `MinReputation`
|
|
70
84
|
Require a minimum Vine reputation score for a season.
|
|
71
85
|
```typescript
|
|
@@ -127,6 +141,18 @@ GateCriteriaFactory.multiDao({
|
|
|
127
141
|
})
|
|
128
142
|
```
|
|
129
143
|
|
|
144
|
+
```typescript
|
|
145
|
+
await client.checkGate({
|
|
146
|
+
gateId,
|
|
147
|
+
user: userWallet,
|
|
148
|
+
remainingAccounts: [
|
|
149
|
+
{ pubkey: checkRecordA, isWritable: false, isSigner: false },
|
|
150
|
+
{ pubkey: checkRecordB, isWritable: false, isSigner: false },
|
|
151
|
+
{ pubkey: checkRecordC, isWritable: false, isSigner: false },
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
130
156
|
### `TokenHolding`
|
|
131
157
|
Require holding a minimum amount of a specific token.
|
|
132
158
|
```typescript
|
|
@@ -146,6 +172,39 @@ GateCriteriaFactory.nftCollection({
|
|
|
146
172
|
})
|
|
147
173
|
```
|
|
148
174
|
|
|
175
|
+
```typescript
|
|
176
|
+
await client.checkGate({
|
|
177
|
+
gateId,
|
|
178
|
+
user: userWallet,
|
|
179
|
+
remainingAccounts: metadataAccounts.map((pubkey) => ({
|
|
180
|
+
pubkey,
|
|
181
|
+
isWritable: false,
|
|
182
|
+
isSigner: false,
|
|
183
|
+
})),
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### `CustomProgram`
|
|
188
|
+
Require a validation account from another program. The SDK expects a 32-byte instruction hash.
|
|
189
|
+
```typescript
|
|
190
|
+
import { createHash } from "crypto";
|
|
191
|
+
|
|
192
|
+
const instructionDataHash = createHash("sha256").update(myInstructionBytes).digest();
|
|
193
|
+
|
|
194
|
+
GateCriteriaFactory.customProgram({
|
|
195
|
+
programId: myProgramId,
|
|
196
|
+
instructionDataHash, // must be 32 bytes
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
await client.checkGate({
|
|
200
|
+
gateId,
|
|
201
|
+
user: userWallet,
|
|
202
|
+
remainingAccounts: [
|
|
203
|
+
{ pubkey: customValidationAccount, isWritable: false, isSigner: false },
|
|
204
|
+
],
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
149
208
|
---
|
|
150
209
|
|
|
151
210
|
## Gate Types
|
|
@@ -168,7 +227,7 @@ import {
|
|
|
168
227
|
findVineReputationPda,
|
|
169
228
|
findGrapeIdentityPda,
|
|
170
229
|
findGrapeLinkPda,
|
|
171
|
-
} from "@
|
|
230
|
+
} from "@grapenpm/gpass-sdk";
|
|
172
231
|
|
|
173
232
|
// Gate PDA
|
|
174
233
|
const [gatePda] = await findGatePda(gateId);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Program, AnchorProvider } from '@coral-xyz/anchor';
|
|
2
|
-
import { PublicKey, TransactionInstruction, Transaction } from '@solana/web3.js';
|
|
2
|
+
import { PublicKey, AccountMeta, Signer, TransactionInstruction, Transaction } from '@solana/web3.js';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
|
|
5
5
|
type GrapeGatingProtocol = {
|
|
@@ -844,7 +844,15 @@ declare const GateCriteriaFactory: {
|
|
|
844
844
|
}) => GateCriteria;
|
|
845
845
|
customProgram: (params: {
|
|
846
846
|
programId: PublicKey;
|
|
847
|
-
|
|
847
|
+
/**
|
|
848
|
+
* 32-byte hash expected by the on-chain validation account.
|
|
849
|
+
* Prefer this field.
|
|
850
|
+
*/
|
|
851
|
+
instructionDataHash?: Buffer | Uint8Array;
|
|
852
|
+
/**
|
|
853
|
+
* @deprecated Use instructionDataHash.
|
|
854
|
+
*/
|
|
855
|
+
instructionData?: Buffer | Uint8Array;
|
|
848
856
|
}) => GateCriteria;
|
|
849
857
|
};
|
|
850
858
|
interface Gate {
|
|
@@ -874,6 +882,11 @@ interface InitializeGateParams {
|
|
|
874
882
|
gateType: GateType;
|
|
875
883
|
/** Defaults to the provider wallet */
|
|
876
884
|
authority?: PublicKey;
|
|
885
|
+
/**
|
|
886
|
+
* Required if authority is not the provider wallet.
|
|
887
|
+
* This signer must correspond to `authority`.
|
|
888
|
+
*/
|
|
889
|
+
authoritySigner?: Signer;
|
|
877
890
|
}
|
|
878
891
|
interface CheckGateParams {
|
|
879
892
|
gateId: PublicKey;
|
|
@@ -888,6 +901,12 @@ interface CheckGateParams {
|
|
|
888
901
|
tokenAccount?: PublicKey;
|
|
889
902
|
/** If true, creates/updates a GateCheckRecord PDA on-chain */
|
|
890
903
|
storeRecord?: boolean;
|
|
904
|
+
/**
|
|
905
|
+
* Extra accounts forwarded to the instruction.
|
|
906
|
+
* Required for criteria that read `remaining_accounts`
|
|
907
|
+
* (e.g. MultiDao, NftCollection, CustomProgram).
|
|
908
|
+
*/
|
|
909
|
+
remainingAccounts?: AccountMeta[];
|
|
891
910
|
}
|
|
892
911
|
interface UpdateGateCriteriaParams {
|
|
893
912
|
gateId: PublicKey;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Program, AnchorProvider } from '@coral-xyz/anchor';
|
|
2
|
-
import { PublicKey, TransactionInstruction, Transaction } from '@solana/web3.js';
|
|
2
|
+
import { PublicKey, AccountMeta, Signer, TransactionInstruction, Transaction } from '@solana/web3.js';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
|
|
5
5
|
type GrapeGatingProtocol = {
|
|
@@ -844,7 +844,15 @@ declare const GateCriteriaFactory: {
|
|
|
844
844
|
}) => GateCriteria;
|
|
845
845
|
customProgram: (params: {
|
|
846
846
|
programId: PublicKey;
|
|
847
|
-
|
|
847
|
+
/**
|
|
848
|
+
* 32-byte hash expected by the on-chain validation account.
|
|
849
|
+
* Prefer this field.
|
|
850
|
+
*/
|
|
851
|
+
instructionDataHash?: Buffer | Uint8Array;
|
|
852
|
+
/**
|
|
853
|
+
* @deprecated Use instructionDataHash.
|
|
854
|
+
*/
|
|
855
|
+
instructionData?: Buffer | Uint8Array;
|
|
848
856
|
}) => GateCriteria;
|
|
849
857
|
};
|
|
850
858
|
interface Gate {
|
|
@@ -874,6 +882,11 @@ interface InitializeGateParams {
|
|
|
874
882
|
gateType: GateType;
|
|
875
883
|
/** Defaults to the provider wallet */
|
|
876
884
|
authority?: PublicKey;
|
|
885
|
+
/**
|
|
886
|
+
* Required if authority is not the provider wallet.
|
|
887
|
+
* This signer must correspond to `authority`.
|
|
888
|
+
*/
|
|
889
|
+
authoritySigner?: Signer;
|
|
877
890
|
}
|
|
878
891
|
interface CheckGateParams {
|
|
879
892
|
gateId: PublicKey;
|
|
@@ -888,6 +901,12 @@ interface CheckGateParams {
|
|
|
888
901
|
tokenAccount?: PublicKey;
|
|
889
902
|
/** If true, creates/updates a GateCheckRecord PDA on-chain */
|
|
890
903
|
storeRecord?: boolean;
|
|
904
|
+
/**
|
|
905
|
+
* Extra accounts forwarded to the instruction.
|
|
906
|
+
* Required for criteria that read `remaining_accounts`
|
|
907
|
+
* (e.g. MultiDao, NftCollection, CustomProgram).
|
|
908
|
+
*/
|
|
909
|
+
remainingAccounts?: AccountMeta[];
|
|
891
910
|
}
|
|
892
911
|
interface UpdateGateCriteriaParams {
|
|
893
912
|
gateId: PublicKey;
|