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