@solana/token-acl-gate-sdk 0.0.0 → 0.2.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.
Files changed (43) hide show
  1. package/dist/src/index.js +740 -0
  2. package/dist/src/index.js.map +1 -0
  3. package/dist/src/index.mjs +665 -0
  4. package/dist/src/index.mjs.map +1 -0
  5. package/dist/types/generated/accounts/index.d.ts +10 -0
  6. package/dist/types/generated/accounts/index.d.ts.map +1 -0
  7. package/dist/types/generated/accounts/listConfig.d.ts +41 -0
  8. package/dist/types/generated/accounts/listConfig.d.ts.map +1 -0
  9. package/dist/types/generated/accounts/walletEntry.d.ts +37 -0
  10. package/dist/types/generated/accounts/walletEntry.d.ts.map +1 -0
  11. package/dist/types/generated/index.d.ts +13 -0
  12. package/dist/types/generated/index.d.ts.map +1 -0
  13. package/dist/types/generated/instructions/addWallet.d.ts +63 -0
  14. package/dist/types/generated/instructions/addWallet.d.ts.map +1 -0
  15. package/dist/types/generated/instructions/createList.d.ts +65 -0
  16. package/dist/types/generated/instructions/createList.d.ts.map +1 -0
  17. package/dist/types/generated/instructions/deleteList.d.ts +40 -0
  18. package/dist/types/generated/instructions/deleteList.d.ts.map +1 -0
  19. package/dist/types/generated/instructions/index.d.ts +13 -0
  20. package/dist/types/generated/instructions/index.d.ts.map +1 -0
  21. package/dist/types/generated/instructions/removeWallet.d.ts +43 -0
  22. package/dist/types/generated/instructions/removeWallet.d.ts.map +1 -0
  23. package/dist/types/generated/instructions/setupExtraMetas.d.ts +53 -0
  24. package/dist/types/generated/instructions/setupExtraMetas.d.ts.map +1 -0
  25. package/dist/types/generated/pdas/index.d.ts +10 -0
  26. package/dist/types/generated/pdas/index.d.ts.map +1 -0
  27. package/dist/types/generated/pdas/listConfig.d.ts +16 -0
  28. package/dist/types/generated/pdas/listConfig.d.ts.map +1 -0
  29. package/dist/types/generated/pdas/walletEntry.d.ts +16 -0
  30. package/dist/types/generated/pdas/walletEntry.d.ts.map +1 -0
  31. package/dist/types/generated/programs/index.d.ts +9 -0
  32. package/dist/types/generated/programs/index.d.ts.map +1 -0
  33. package/dist/types/generated/programs/tokenAclGateProgram.d.ts +39 -0
  34. package/dist/types/generated/programs/tokenAclGateProgram.d.ts.map +1 -0
  35. package/dist/types/generated/shared/index.d.ts +50 -0
  36. package/dist/types/generated/shared/index.d.ts.map +1 -0
  37. package/dist/types/generated/types/index.d.ts +9 -0
  38. package/dist/types/generated/types/index.d.ts.map +1 -0
  39. package/dist/types/generated/types/mode.d.ts +18 -0
  40. package/dist/types/generated/types/mode.d.ts.map +1 -0
  41. package/dist/types/index.d.ts +2 -0
  42. package/dist/types/index.d.ts.map +1 -0
  43. package/package.json +71 -7
@@ -0,0 +1,740 @@
1
+ 'use strict';
2
+
3
+ var kit = require('@solana/kit');
4
+
5
+ // src/generated/accounts/listConfig.ts
6
+ async function findListConfigPda(seeds, config = {}) {
7
+ const {
8
+ programAddress = "GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz"
9
+ } = config;
10
+ return await kit.getProgramDerivedAddress({
11
+ programAddress,
12
+ seeds: [
13
+ kit.getUtf8Encoder().encode("list_config"),
14
+ kit.getAddressEncoder().encode(seeds.authority),
15
+ kit.getAddressEncoder().encode(seeds.seed)
16
+ ]
17
+ });
18
+ }
19
+ async function findWalletEntryPda(seeds, config = {}) {
20
+ const {
21
+ programAddress = "GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz"
22
+ } = config;
23
+ return await kit.getProgramDerivedAddress({
24
+ programAddress,
25
+ seeds: [
26
+ kit.getUtf8Encoder().encode("wallet_entry"),
27
+ kit.getAddressEncoder().encode(seeds.listConfig),
28
+ kit.getAddressEncoder().encode(seeds.wallet)
29
+ ]
30
+ });
31
+ }
32
+
33
+ // src/generated/accounts/listConfig.ts
34
+ var LIST_CONFIG_DISCRIMINATOR = 1;
35
+ function getListConfigDiscriminatorBytes() {
36
+ return kit.getU8Encoder().encode(LIST_CONFIG_DISCRIMINATOR);
37
+ }
38
+ function getListConfigEncoder() {
39
+ return kit.transformEncoder(
40
+ kit.getStructEncoder([
41
+ ["discriminator", kit.getU8Encoder()],
42
+ ["authority", kit.getAddressEncoder()],
43
+ ["seed", kit.getAddressEncoder()],
44
+ ["mode", kit.getU8Encoder()],
45
+ ["walletsCount", kit.getU64Encoder()]
46
+ ]),
47
+ (value) => ({ ...value, discriminator: LIST_CONFIG_DISCRIMINATOR })
48
+ );
49
+ }
50
+ function getListConfigDecoder() {
51
+ return kit.getStructDecoder([
52
+ ["discriminator", kit.getU8Decoder()],
53
+ ["authority", kit.getAddressDecoder()],
54
+ ["seed", kit.getAddressDecoder()],
55
+ ["mode", kit.getU8Decoder()],
56
+ ["walletsCount", kit.getU64Decoder()]
57
+ ]);
58
+ }
59
+ function getListConfigCodec() {
60
+ return kit.combineCodec(getListConfigEncoder(), getListConfigDecoder());
61
+ }
62
+ function decodeListConfig(encodedAccount) {
63
+ return kit.decodeAccount(
64
+ encodedAccount,
65
+ getListConfigDecoder()
66
+ );
67
+ }
68
+ async function fetchListConfig(rpc, address, config) {
69
+ const maybeAccount = await fetchMaybeListConfig(rpc, address, config);
70
+ kit.assertAccountExists(maybeAccount);
71
+ return maybeAccount;
72
+ }
73
+ async function fetchMaybeListConfig(rpc, address, config) {
74
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
75
+ return decodeListConfig(maybeAccount);
76
+ }
77
+ async function fetchAllListConfig(rpc, addresses, config) {
78
+ const maybeAccounts = await fetchAllMaybeListConfig(rpc, addresses, config);
79
+ kit.assertAccountsExist(maybeAccounts);
80
+ return maybeAccounts;
81
+ }
82
+ async function fetchAllMaybeListConfig(rpc, addresses, config) {
83
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
84
+ return maybeAccounts.map((maybeAccount) => decodeListConfig(maybeAccount));
85
+ }
86
+ function getListConfigSize() {
87
+ return 74;
88
+ }
89
+ async function fetchListConfigFromSeeds(rpc, seeds, config = {}) {
90
+ const maybeAccount = await fetchMaybeListConfigFromSeeds(rpc, seeds, config);
91
+ kit.assertAccountExists(maybeAccount);
92
+ return maybeAccount;
93
+ }
94
+ async function fetchMaybeListConfigFromSeeds(rpc, seeds, config = {}) {
95
+ const { programAddress, ...fetchConfig } = config;
96
+ const [address] = await findListConfigPda(seeds, { programAddress });
97
+ return await fetchMaybeListConfig(rpc, address, fetchConfig);
98
+ }
99
+ var WALLET_ENTRY_DISCRIMINATOR = 2;
100
+ function getWalletEntryDiscriminatorBytes() {
101
+ return kit.getU8Encoder().encode(WALLET_ENTRY_DISCRIMINATOR);
102
+ }
103
+ function getWalletEntryEncoder() {
104
+ return kit.transformEncoder(
105
+ kit.getStructEncoder([
106
+ ["discriminator", kit.getU8Encoder()],
107
+ ["walletAddress", kit.getAddressEncoder()],
108
+ ["listConfig", kit.getAddressEncoder()]
109
+ ]),
110
+ (value) => ({ ...value, discriminator: WALLET_ENTRY_DISCRIMINATOR })
111
+ );
112
+ }
113
+ function getWalletEntryDecoder() {
114
+ return kit.getStructDecoder([
115
+ ["discriminator", kit.getU8Decoder()],
116
+ ["walletAddress", kit.getAddressDecoder()],
117
+ ["listConfig", kit.getAddressDecoder()]
118
+ ]);
119
+ }
120
+ function getWalletEntryCodec() {
121
+ return kit.combineCodec(getWalletEntryEncoder(), getWalletEntryDecoder());
122
+ }
123
+ function decodeWalletEntry(encodedAccount) {
124
+ return kit.decodeAccount(
125
+ encodedAccount,
126
+ getWalletEntryDecoder()
127
+ );
128
+ }
129
+ async function fetchWalletEntry(rpc, address, config) {
130
+ const maybeAccount = await fetchMaybeWalletEntry(rpc, address, config);
131
+ kit.assertAccountExists(maybeAccount);
132
+ return maybeAccount;
133
+ }
134
+ async function fetchMaybeWalletEntry(rpc, address, config) {
135
+ const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
136
+ return decodeWalletEntry(maybeAccount);
137
+ }
138
+ async function fetchAllWalletEntry(rpc, addresses, config) {
139
+ const maybeAccounts = await fetchAllMaybeWalletEntry(rpc, addresses, config);
140
+ kit.assertAccountsExist(maybeAccounts);
141
+ return maybeAccounts;
142
+ }
143
+ async function fetchAllMaybeWalletEntry(rpc, addresses, config) {
144
+ const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
145
+ return maybeAccounts.map((maybeAccount) => decodeWalletEntry(maybeAccount));
146
+ }
147
+ function getWalletEntrySize() {
148
+ return 65;
149
+ }
150
+ async function fetchWalletEntryFromSeeds(rpc, seeds, config = {}) {
151
+ const maybeAccount = await fetchMaybeWalletEntryFromSeeds(rpc, seeds, config);
152
+ kit.assertAccountExists(maybeAccount);
153
+ return maybeAccount;
154
+ }
155
+ async function fetchMaybeWalletEntryFromSeeds(rpc, seeds, config = {}) {
156
+ const { programAddress, ...fetchConfig } = config;
157
+ const [address] = await findWalletEntryPda(seeds, { programAddress });
158
+ return await fetchMaybeWalletEntry(rpc, address, fetchConfig);
159
+ }
160
+ var TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS = "GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz";
161
+ var TokenAclGateProgramAccount = /* @__PURE__ */ ((TokenAclGateProgramAccount2) => {
162
+ TokenAclGateProgramAccount2[TokenAclGateProgramAccount2["ListConfig"] = 0] = "ListConfig";
163
+ TokenAclGateProgramAccount2[TokenAclGateProgramAccount2["WalletEntry"] = 1] = "WalletEntry";
164
+ return TokenAclGateProgramAccount2;
165
+ })(TokenAclGateProgramAccount || {});
166
+ function identifyTokenAclGateProgramAccount(account) {
167
+ const data = "data" in account ? account.data : account;
168
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(1), 0)) {
169
+ return 0 /* ListConfig */;
170
+ }
171
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0)) {
172
+ return 1 /* WalletEntry */;
173
+ }
174
+ throw new Error(
175
+ "The provided account could not be identified as a token-acl-gate-program account."
176
+ );
177
+ }
178
+ var TokenAclGateProgramInstruction = /* @__PURE__ */ ((TokenAclGateProgramInstruction2) => {
179
+ TokenAclGateProgramInstruction2[TokenAclGateProgramInstruction2["CreateList"] = 0] = "CreateList";
180
+ TokenAclGateProgramInstruction2[TokenAclGateProgramInstruction2["AddWallet"] = 1] = "AddWallet";
181
+ TokenAclGateProgramInstruction2[TokenAclGateProgramInstruction2["RemoveWallet"] = 2] = "RemoveWallet";
182
+ TokenAclGateProgramInstruction2[TokenAclGateProgramInstruction2["SetupExtraMetas"] = 3] = "SetupExtraMetas";
183
+ TokenAclGateProgramInstruction2[TokenAclGateProgramInstruction2["DeleteList"] = 4] = "DeleteList";
184
+ return TokenAclGateProgramInstruction2;
185
+ })(TokenAclGateProgramInstruction || {});
186
+ function identifyTokenAclGateProgramInstruction(instruction) {
187
+ const data = "data" in instruction ? instruction.data : instruction;
188
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(1), 0)) {
189
+ return 0 /* CreateList */;
190
+ }
191
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0)) {
192
+ return 1 /* AddWallet */;
193
+ }
194
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(3), 0)) {
195
+ return 2 /* RemoveWallet */;
196
+ }
197
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(4), 0)) {
198
+ return 3 /* SetupExtraMetas */;
199
+ }
200
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(5), 0)) {
201
+ return 4 /* DeleteList */;
202
+ }
203
+ throw new Error(
204
+ "The provided instruction could not be identified as a token-acl-gate-program instruction."
205
+ );
206
+ }
207
+ function expectSome(value) {
208
+ if (value === null || value === void 0) {
209
+ throw new Error("Expected a value but received null or undefined.");
210
+ }
211
+ return value;
212
+ }
213
+ function expectAddress(value) {
214
+ if (!value) {
215
+ throw new Error("Expected a Address.");
216
+ }
217
+ if (typeof value === "object" && "address" in value) {
218
+ return value.address;
219
+ }
220
+ if (Array.isArray(value)) {
221
+ return value[0];
222
+ }
223
+ return value;
224
+ }
225
+ function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
226
+ return (account) => {
227
+ if (!account.value) {
228
+ return Object.freeze({
229
+ address: programAddress,
230
+ role: kit.AccountRole.READONLY
231
+ });
232
+ }
233
+ const writableRole = account.isWritable ? kit.AccountRole.WRITABLE : kit.AccountRole.READONLY;
234
+ return Object.freeze({
235
+ address: expectAddress(account.value),
236
+ role: isTransactionSigner(account.value) ? kit.upgradeRoleToSigner(writableRole) : writableRole,
237
+ ...isTransactionSigner(account.value) ? { signer: account.value } : {}
238
+ });
239
+ };
240
+ }
241
+ function isTransactionSigner(value) {
242
+ return !!value && typeof value === "object" && "address" in value && kit.isTransactionSigner(value);
243
+ }
244
+
245
+ // src/generated/instructions/addWallet.ts
246
+ var ADD_WALLET_DISCRIMINATOR = 2;
247
+ function getAddWalletDiscriminatorBytes() {
248
+ return kit.getU8Encoder().encode(ADD_WALLET_DISCRIMINATOR);
249
+ }
250
+ function getAddWalletInstructionDataEncoder() {
251
+ return kit.transformEncoder(
252
+ kit.getStructEncoder([["discriminator", kit.getU8Encoder()]]),
253
+ (value) => ({ ...value, discriminator: ADD_WALLET_DISCRIMINATOR })
254
+ );
255
+ }
256
+ function getAddWalletInstructionDataDecoder() {
257
+ return kit.getStructDecoder([["discriminator", kit.getU8Decoder()]]);
258
+ }
259
+ function getAddWalletInstructionDataCodec() {
260
+ return kit.combineCodec(
261
+ getAddWalletInstructionDataEncoder(),
262
+ getAddWalletInstructionDataDecoder()
263
+ );
264
+ }
265
+ async function getAddWalletInstructionAsync(input, config) {
266
+ const programAddress = config?.programAddress ?? TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
267
+ const originalAccounts = {
268
+ authority: { value: input.authority ?? null, isWritable: false },
269
+ payer: { value: input.payer ?? null, isWritable: true },
270
+ listConfig: { value: input.listConfig ?? null, isWritable: true },
271
+ wallet: { value: input.wallet ?? null, isWritable: false },
272
+ walletEntry: { value: input.walletEntry ?? null, isWritable: true },
273
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
274
+ };
275
+ const accounts = originalAccounts;
276
+ if (!accounts.walletEntry.value) {
277
+ accounts.walletEntry.value = await findWalletEntryPda({
278
+ listConfig: expectAddress(accounts.listConfig.value),
279
+ wallet: expectAddress(accounts.wallet.value)
280
+ });
281
+ }
282
+ if (!accounts.systemProgram.value) {
283
+ accounts.systemProgram.value = "11111111111111111111111111111111";
284
+ }
285
+ const getAccountMeta = getAccountMetaFactory(programAddress);
286
+ return Object.freeze({
287
+ accounts: [
288
+ getAccountMeta(accounts.authority),
289
+ getAccountMeta(accounts.payer),
290
+ getAccountMeta(accounts.listConfig),
291
+ getAccountMeta(accounts.wallet),
292
+ getAccountMeta(accounts.walletEntry),
293
+ getAccountMeta(accounts.systemProgram)
294
+ ],
295
+ data: getAddWalletInstructionDataEncoder().encode({}),
296
+ programAddress
297
+ });
298
+ }
299
+ function getAddWalletInstruction(input, config) {
300
+ const programAddress = config?.programAddress ?? TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
301
+ const originalAccounts = {
302
+ authority: { value: input.authority ?? null, isWritable: false },
303
+ payer: { value: input.payer ?? null, isWritable: true },
304
+ listConfig: { value: input.listConfig ?? null, isWritable: true },
305
+ wallet: { value: input.wallet ?? null, isWritable: false },
306
+ walletEntry: { value: input.walletEntry ?? null, isWritable: true },
307
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
308
+ };
309
+ const accounts = originalAccounts;
310
+ if (!accounts.systemProgram.value) {
311
+ accounts.systemProgram.value = "11111111111111111111111111111111";
312
+ }
313
+ const getAccountMeta = getAccountMetaFactory(programAddress);
314
+ return Object.freeze({
315
+ accounts: [
316
+ getAccountMeta(accounts.authority),
317
+ getAccountMeta(accounts.payer),
318
+ getAccountMeta(accounts.listConfig),
319
+ getAccountMeta(accounts.wallet),
320
+ getAccountMeta(accounts.walletEntry),
321
+ getAccountMeta(accounts.systemProgram)
322
+ ],
323
+ data: getAddWalletInstructionDataEncoder().encode({}),
324
+ programAddress
325
+ });
326
+ }
327
+ function parseAddWalletInstruction(instruction) {
328
+ if (instruction.accounts.length < 6) {
329
+ throw new Error("Not enough accounts");
330
+ }
331
+ let accountIndex = 0;
332
+ const getNextAccount = () => {
333
+ const accountMeta = instruction.accounts[accountIndex];
334
+ accountIndex += 1;
335
+ return accountMeta;
336
+ };
337
+ return {
338
+ programAddress: instruction.programAddress,
339
+ accounts: {
340
+ authority: getNextAccount(),
341
+ payer: getNextAccount(),
342
+ listConfig: getNextAccount(),
343
+ wallet: getNextAccount(),
344
+ walletEntry: getNextAccount(),
345
+ systemProgram: getNextAccount()
346
+ },
347
+ data: getAddWalletInstructionDataDecoder().decode(instruction.data)
348
+ };
349
+ }
350
+ var Mode = /* @__PURE__ */ ((Mode2) => {
351
+ Mode2[Mode2["Allow"] = 0] = "Allow";
352
+ Mode2[Mode2["AllowAllEoas"] = 1] = "AllowAllEoas";
353
+ Mode2[Mode2["Block"] = 2] = "Block";
354
+ return Mode2;
355
+ })(Mode || {});
356
+ function getModeEncoder() {
357
+ return kit.getEnumEncoder(Mode);
358
+ }
359
+ function getModeDecoder() {
360
+ return kit.getEnumDecoder(Mode);
361
+ }
362
+ function getModeCodec() {
363
+ return kit.combineCodec(getModeEncoder(), getModeDecoder());
364
+ }
365
+
366
+ // src/generated/instructions/createList.ts
367
+ var CREATE_LIST_DISCRIMINATOR = 1;
368
+ function getCreateListDiscriminatorBytes() {
369
+ return kit.getU8Encoder().encode(CREATE_LIST_DISCRIMINATOR);
370
+ }
371
+ function getCreateListInstructionDataEncoder() {
372
+ return kit.transformEncoder(
373
+ kit.getStructEncoder([
374
+ ["discriminator", kit.getU8Encoder()],
375
+ ["mode", getModeEncoder()],
376
+ ["seed", kit.getAddressEncoder()]
377
+ ]),
378
+ (value) => ({ ...value, discriminator: CREATE_LIST_DISCRIMINATOR })
379
+ );
380
+ }
381
+ function getCreateListInstructionDataDecoder() {
382
+ return kit.getStructDecoder([
383
+ ["discriminator", kit.getU8Decoder()],
384
+ ["mode", getModeDecoder()],
385
+ ["seed", kit.getAddressDecoder()]
386
+ ]);
387
+ }
388
+ function getCreateListInstructionDataCodec() {
389
+ return kit.combineCodec(
390
+ getCreateListInstructionDataEncoder(),
391
+ getCreateListInstructionDataDecoder()
392
+ );
393
+ }
394
+ async function getCreateListInstructionAsync(input, config) {
395
+ const programAddress = config?.programAddress ?? TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
396
+ const originalAccounts = {
397
+ authority: { value: input.authority ?? null, isWritable: false },
398
+ payer: { value: input.payer ?? null, isWritable: true },
399
+ listConfig: { value: input.listConfig ?? null, isWritable: true },
400
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
401
+ };
402
+ const accounts = originalAccounts;
403
+ const args = { ...input };
404
+ if (!accounts.listConfig.value) {
405
+ accounts.listConfig.value = await findListConfigPda({
406
+ authority: expectAddress(accounts.authority.value),
407
+ seed: expectSome(args.seed)
408
+ });
409
+ }
410
+ if (!accounts.systemProgram.value) {
411
+ accounts.systemProgram.value = "11111111111111111111111111111111";
412
+ }
413
+ const getAccountMeta = getAccountMetaFactory(programAddress);
414
+ return Object.freeze({
415
+ accounts: [
416
+ getAccountMeta(accounts.authority),
417
+ getAccountMeta(accounts.payer),
418
+ getAccountMeta(accounts.listConfig),
419
+ getAccountMeta(accounts.systemProgram)
420
+ ],
421
+ data: getCreateListInstructionDataEncoder().encode(
422
+ args
423
+ ),
424
+ programAddress
425
+ });
426
+ }
427
+ function getCreateListInstruction(input, config) {
428
+ const programAddress = config?.programAddress ?? TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
429
+ const originalAccounts = {
430
+ authority: { value: input.authority ?? null, isWritable: false },
431
+ payer: { value: input.payer ?? null, isWritable: true },
432
+ listConfig: { value: input.listConfig ?? null, isWritable: true },
433
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
434
+ };
435
+ const accounts = originalAccounts;
436
+ const args = { ...input };
437
+ if (!accounts.systemProgram.value) {
438
+ accounts.systemProgram.value = "11111111111111111111111111111111";
439
+ }
440
+ const getAccountMeta = getAccountMetaFactory(programAddress);
441
+ return Object.freeze({
442
+ accounts: [
443
+ getAccountMeta(accounts.authority),
444
+ getAccountMeta(accounts.payer),
445
+ getAccountMeta(accounts.listConfig),
446
+ getAccountMeta(accounts.systemProgram)
447
+ ],
448
+ data: getCreateListInstructionDataEncoder().encode(
449
+ args
450
+ ),
451
+ programAddress
452
+ });
453
+ }
454
+ function parseCreateListInstruction(instruction) {
455
+ if (instruction.accounts.length < 4) {
456
+ throw new Error("Not enough accounts");
457
+ }
458
+ let accountIndex = 0;
459
+ const getNextAccount = () => {
460
+ const accountMeta = instruction.accounts[accountIndex];
461
+ accountIndex += 1;
462
+ return accountMeta;
463
+ };
464
+ return {
465
+ programAddress: instruction.programAddress,
466
+ accounts: {
467
+ authority: getNextAccount(),
468
+ payer: getNextAccount(),
469
+ listConfig: getNextAccount(),
470
+ systemProgram: getNextAccount()
471
+ },
472
+ data: getCreateListInstructionDataDecoder().decode(instruction.data)
473
+ };
474
+ }
475
+ var DELETE_LIST_DISCRIMINATOR = 5;
476
+ function getDeleteListDiscriminatorBytes() {
477
+ return kit.getU8Encoder().encode(DELETE_LIST_DISCRIMINATOR);
478
+ }
479
+ function getDeleteListInstructionDataEncoder() {
480
+ return kit.transformEncoder(
481
+ kit.getStructEncoder([["discriminator", kit.getU8Encoder()]]),
482
+ (value) => ({ ...value, discriminator: DELETE_LIST_DISCRIMINATOR })
483
+ );
484
+ }
485
+ function getDeleteListInstructionDataDecoder() {
486
+ return kit.getStructDecoder([["discriminator", kit.getU8Decoder()]]);
487
+ }
488
+ function getDeleteListInstructionDataCodec() {
489
+ return kit.combineCodec(
490
+ getDeleteListInstructionDataEncoder(),
491
+ getDeleteListInstructionDataDecoder()
492
+ );
493
+ }
494
+ function getDeleteListInstruction(input, config) {
495
+ const programAddress = config?.programAddress ?? TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
496
+ const originalAccounts = {
497
+ authority: { value: input.authority ?? null, isWritable: true },
498
+ listConfig: { value: input.listConfig ?? null, isWritable: true }
499
+ };
500
+ const accounts = originalAccounts;
501
+ const getAccountMeta = getAccountMetaFactory(programAddress);
502
+ return Object.freeze({
503
+ accounts: [
504
+ getAccountMeta(accounts.authority),
505
+ getAccountMeta(accounts.listConfig)
506
+ ],
507
+ data: getDeleteListInstructionDataEncoder().encode({}),
508
+ programAddress
509
+ });
510
+ }
511
+ function parseDeleteListInstruction(instruction) {
512
+ if (instruction.accounts.length < 2) {
513
+ throw new Error("Not enough accounts");
514
+ }
515
+ let accountIndex = 0;
516
+ const getNextAccount = () => {
517
+ const accountMeta = instruction.accounts[accountIndex];
518
+ accountIndex += 1;
519
+ return accountMeta;
520
+ };
521
+ return {
522
+ programAddress: instruction.programAddress,
523
+ accounts: { authority: getNextAccount(), listConfig: getNextAccount() },
524
+ data: getDeleteListInstructionDataDecoder().decode(instruction.data)
525
+ };
526
+ }
527
+ var REMOVE_WALLET_DISCRIMINATOR = 3;
528
+ function getRemoveWalletDiscriminatorBytes() {
529
+ return kit.getU8Encoder().encode(REMOVE_WALLET_DISCRIMINATOR);
530
+ }
531
+ function getRemoveWalletInstructionDataEncoder() {
532
+ return kit.transformEncoder(
533
+ kit.getStructEncoder([["discriminator", kit.getU8Encoder()]]),
534
+ (value) => ({ ...value, discriminator: REMOVE_WALLET_DISCRIMINATOR })
535
+ );
536
+ }
537
+ function getRemoveWalletInstructionDataDecoder() {
538
+ return kit.getStructDecoder([["discriminator", kit.getU8Decoder()]]);
539
+ }
540
+ function getRemoveWalletInstructionDataCodec() {
541
+ return kit.combineCodec(
542
+ getRemoveWalletInstructionDataEncoder(),
543
+ getRemoveWalletInstructionDataDecoder()
544
+ );
545
+ }
546
+ function getRemoveWalletInstruction(input, config) {
547
+ const programAddress = config?.programAddress ?? TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
548
+ const originalAccounts = {
549
+ authority: { value: input.authority ?? null, isWritable: true },
550
+ listConfig: { value: input.listConfig ?? null, isWritable: true },
551
+ walletEntry: { value: input.walletEntry ?? null, isWritable: true }
552
+ };
553
+ const accounts = originalAccounts;
554
+ const getAccountMeta = getAccountMetaFactory(programAddress);
555
+ return Object.freeze({
556
+ accounts: [
557
+ getAccountMeta(accounts.authority),
558
+ getAccountMeta(accounts.listConfig),
559
+ getAccountMeta(accounts.walletEntry)
560
+ ],
561
+ data: getRemoveWalletInstructionDataEncoder().encode({}),
562
+ programAddress
563
+ });
564
+ }
565
+ function parseRemoveWalletInstruction(instruction) {
566
+ if (instruction.accounts.length < 3) {
567
+ throw new Error("Not enough accounts");
568
+ }
569
+ let accountIndex = 0;
570
+ const getNextAccount = () => {
571
+ const accountMeta = instruction.accounts[accountIndex];
572
+ accountIndex += 1;
573
+ return accountMeta;
574
+ };
575
+ return {
576
+ programAddress: instruction.programAddress,
577
+ accounts: {
578
+ authority: getNextAccount(),
579
+ listConfig: getNextAccount(),
580
+ walletEntry: getNextAccount()
581
+ },
582
+ data: getRemoveWalletInstructionDataDecoder().decode(instruction.data)
583
+ };
584
+ }
585
+ var SETUP_EXTRA_METAS_DISCRIMINATOR = 4;
586
+ function getSetupExtraMetasDiscriminatorBytes() {
587
+ return kit.getU8Encoder().encode(SETUP_EXTRA_METAS_DISCRIMINATOR);
588
+ }
589
+ function getSetupExtraMetasInstructionDataEncoder() {
590
+ return kit.transformEncoder(
591
+ kit.getStructEncoder([["discriminator", kit.getU8Encoder()]]),
592
+ (value) => ({ ...value, discriminator: SETUP_EXTRA_METAS_DISCRIMINATOR })
593
+ );
594
+ }
595
+ function getSetupExtraMetasInstructionDataDecoder() {
596
+ return kit.getStructDecoder([["discriminator", kit.getU8Decoder()]]);
597
+ }
598
+ function getSetupExtraMetasInstructionDataCodec() {
599
+ return kit.combineCodec(
600
+ getSetupExtraMetasInstructionDataEncoder(),
601
+ getSetupExtraMetasInstructionDataDecoder()
602
+ );
603
+ }
604
+ function getSetupExtraMetasInstruction(input, config) {
605
+ const programAddress = config?.programAddress ?? TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
606
+ const originalAccounts = {
607
+ authority: { value: input.authority ?? null, isWritable: false },
608
+ payer: { value: input.payer ?? null, isWritable: true },
609
+ tokenAclMintConfig: {
610
+ value: input.tokenAclMintConfig ?? null,
611
+ isWritable: false
612
+ },
613
+ mint: { value: input.mint ?? null, isWritable: false },
614
+ extraMetas: { value: input.extraMetas ?? null, isWritable: true },
615
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
616
+ };
617
+ const accounts = originalAccounts;
618
+ const args = { ...input };
619
+ if (!accounts.systemProgram.value) {
620
+ accounts.systemProgram.value = "11111111111111111111111111111111";
621
+ }
622
+ const remainingAccounts = args.lists.map((address) => ({
623
+ address,
624
+ role: kit.AccountRole.READONLY
625
+ }));
626
+ const getAccountMeta = getAccountMetaFactory(programAddress);
627
+ return Object.freeze({
628
+ accounts: [
629
+ getAccountMeta(accounts.authority),
630
+ getAccountMeta(accounts.payer),
631
+ getAccountMeta(accounts.tokenAclMintConfig),
632
+ getAccountMeta(accounts.mint),
633
+ getAccountMeta(accounts.extraMetas),
634
+ getAccountMeta(accounts.systemProgram),
635
+ ...remainingAccounts
636
+ ],
637
+ data: getSetupExtraMetasInstructionDataEncoder().encode({}),
638
+ programAddress
639
+ });
640
+ }
641
+ function parseSetupExtraMetasInstruction(instruction) {
642
+ if (instruction.accounts.length < 6) {
643
+ throw new Error("Not enough accounts");
644
+ }
645
+ let accountIndex = 0;
646
+ const getNextAccount = () => {
647
+ const accountMeta = instruction.accounts[accountIndex];
648
+ accountIndex += 1;
649
+ return accountMeta;
650
+ };
651
+ return {
652
+ programAddress: instruction.programAddress,
653
+ accounts: {
654
+ authority: getNextAccount(),
655
+ payer: getNextAccount(),
656
+ tokenAclMintConfig: getNextAccount(),
657
+ mint: getNextAccount(),
658
+ extraMetas: getNextAccount(),
659
+ systemProgram: getNextAccount()
660
+ },
661
+ data: getSetupExtraMetasInstructionDataDecoder().decode(instruction.data)
662
+ };
663
+ }
664
+
665
+ exports.ADD_WALLET_DISCRIMINATOR = ADD_WALLET_DISCRIMINATOR;
666
+ exports.CREATE_LIST_DISCRIMINATOR = CREATE_LIST_DISCRIMINATOR;
667
+ exports.DELETE_LIST_DISCRIMINATOR = DELETE_LIST_DISCRIMINATOR;
668
+ exports.LIST_CONFIG_DISCRIMINATOR = LIST_CONFIG_DISCRIMINATOR;
669
+ exports.Mode = Mode;
670
+ exports.REMOVE_WALLET_DISCRIMINATOR = REMOVE_WALLET_DISCRIMINATOR;
671
+ exports.SETUP_EXTRA_METAS_DISCRIMINATOR = SETUP_EXTRA_METAS_DISCRIMINATOR;
672
+ exports.TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS = TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
673
+ exports.TokenAclGateProgramAccount = TokenAclGateProgramAccount;
674
+ exports.TokenAclGateProgramInstruction = TokenAclGateProgramInstruction;
675
+ exports.WALLET_ENTRY_DISCRIMINATOR = WALLET_ENTRY_DISCRIMINATOR;
676
+ exports.decodeListConfig = decodeListConfig;
677
+ exports.decodeWalletEntry = decodeWalletEntry;
678
+ exports.fetchAllListConfig = fetchAllListConfig;
679
+ exports.fetchAllMaybeListConfig = fetchAllMaybeListConfig;
680
+ exports.fetchAllMaybeWalletEntry = fetchAllMaybeWalletEntry;
681
+ exports.fetchAllWalletEntry = fetchAllWalletEntry;
682
+ exports.fetchListConfig = fetchListConfig;
683
+ exports.fetchListConfigFromSeeds = fetchListConfigFromSeeds;
684
+ exports.fetchMaybeListConfig = fetchMaybeListConfig;
685
+ exports.fetchMaybeListConfigFromSeeds = fetchMaybeListConfigFromSeeds;
686
+ exports.fetchMaybeWalletEntry = fetchMaybeWalletEntry;
687
+ exports.fetchMaybeWalletEntryFromSeeds = fetchMaybeWalletEntryFromSeeds;
688
+ exports.fetchWalletEntry = fetchWalletEntry;
689
+ exports.fetchWalletEntryFromSeeds = fetchWalletEntryFromSeeds;
690
+ exports.findListConfigPda = findListConfigPda;
691
+ exports.findWalletEntryPda = findWalletEntryPda;
692
+ exports.getAddWalletDiscriminatorBytes = getAddWalletDiscriminatorBytes;
693
+ exports.getAddWalletInstruction = getAddWalletInstruction;
694
+ exports.getAddWalletInstructionAsync = getAddWalletInstructionAsync;
695
+ exports.getAddWalletInstructionDataCodec = getAddWalletInstructionDataCodec;
696
+ exports.getAddWalletInstructionDataDecoder = getAddWalletInstructionDataDecoder;
697
+ exports.getAddWalletInstructionDataEncoder = getAddWalletInstructionDataEncoder;
698
+ exports.getCreateListDiscriminatorBytes = getCreateListDiscriminatorBytes;
699
+ exports.getCreateListInstruction = getCreateListInstruction;
700
+ exports.getCreateListInstructionAsync = getCreateListInstructionAsync;
701
+ exports.getCreateListInstructionDataCodec = getCreateListInstructionDataCodec;
702
+ exports.getCreateListInstructionDataDecoder = getCreateListInstructionDataDecoder;
703
+ exports.getCreateListInstructionDataEncoder = getCreateListInstructionDataEncoder;
704
+ exports.getDeleteListDiscriminatorBytes = getDeleteListDiscriminatorBytes;
705
+ exports.getDeleteListInstruction = getDeleteListInstruction;
706
+ exports.getDeleteListInstructionDataCodec = getDeleteListInstructionDataCodec;
707
+ exports.getDeleteListInstructionDataDecoder = getDeleteListInstructionDataDecoder;
708
+ exports.getDeleteListInstructionDataEncoder = getDeleteListInstructionDataEncoder;
709
+ exports.getListConfigCodec = getListConfigCodec;
710
+ exports.getListConfigDecoder = getListConfigDecoder;
711
+ exports.getListConfigDiscriminatorBytes = getListConfigDiscriminatorBytes;
712
+ exports.getListConfigEncoder = getListConfigEncoder;
713
+ exports.getListConfigSize = getListConfigSize;
714
+ exports.getModeCodec = getModeCodec;
715
+ exports.getModeDecoder = getModeDecoder;
716
+ exports.getModeEncoder = getModeEncoder;
717
+ exports.getRemoveWalletDiscriminatorBytes = getRemoveWalletDiscriminatorBytes;
718
+ exports.getRemoveWalletInstruction = getRemoveWalletInstruction;
719
+ exports.getRemoveWalletInstructionDataCodec = getRemoveWalletInstructionDataCodec;
720
+ exports.getRemoveWalletInstructionDataDecoder = getRemoveWalletInstructionDataDecoder;
721
+ exports.getRemoveWalletInstructionDataEncoder = getRemoveWalletInstructionDataEncoder;
722
+ exports.getSetupExtraMetasDiscriminatorBytes = getSetupExtraMetasDiscriminatorBytes;
723
+ exports.getSetupExtraMetasInstruction = getSetupExtraMetasInstruction;
724
+ exports.getSetupExtraMetasInstructionDataCodec = getSetupExtraMetasInstructionDataCodec;
725
+ exports.getSetupExtraMetasInstructionDataDecoder = getSetupExtraMetasInstructionDataDecoder;
726
+ exports.getSetupExtraMetasInstructionDataEncoder = getSetupExtraMetasInstructionDataEncoder;
727
+ exports.getWalletEntryCodec = getWalletEntryCodec;
728
+ exports.getWalletEntryDecoder = getWalletEntryDecoder;
729
+ exports.getWalletEntryDiscriminatorBytes = getWalletEntryDiscriminatorBytes;
730
+ exports.getWalletEntryEncoder = getWalletEntryEncoder;
731
+ exports.getWalletEntrySize = getWalletEntrySize;
732
+ exports.identifyTokenAclGateProgramAccount = identifyTokenAclGateProgramAccount;
733
+ exports.identifyTokenAclGateProgramInstruction = identifyTokenAclGateProgramInstruction;
734
+ exports.parseAddWalletInstruction = parseAddWalletInstruction;
735
+ exports.parseCreateListInstruction = parseCreateListInstruction;
736
+ exports.parseDeleteListInstruction = parseDeleteListInstruction;
737
+ exports.parseRemoveWalletInstruction = parseRemoveWalletInstruction;
738
+ exports.parseSetupExtraMetasInstruction = parseSetupExtraMetasInstruction;
739
+ //# sourceMappingURL=index.js.map
740
+ //# sourceMappingURL=index.js.map