/
setCollection.ts
162 lines (156 loc) · 4.21 KB
/
setCollection.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/**
* This code was GENERATED using the solita package.
* Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality.
*
* See: https://github.com/metaplex-foundation/solita
*/
import * as beet from '@metaplex-foundation/beet';
import * as web3 from '@solana/web3.js';
/**
* @category Instructions
* @category SetCollection
* @category generated
*/
export const setCollectionStruct = new beet.BeetArgsStruct<{
instructionDiscriminator: number[] /* size: 8 */;
}>(
[['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]],
'SetCollectionInstructionArgs',
);
/**
* Accounts required by the _setCollection_ instruction
*
* @property [_writable_] candyMachine
* @property [**signer**] authority
* @property [_writable_] authorityPda
* @property [**signer**] payer
* @property [] collectionMint
* @property [] collectionMetadata
* @property [_writable_] collectionAuthorityRecord
* @property [_writable_, **signer**] newCollectionUpdateAuthority
* @property [] newCollectionMetadata
* @property [] newCollectionMint
* @property [] newCollectionMasterEdition
* @property [_writable_] newCollectionAuthorityRecord
* @property [] tokenMetadataProgram
* @category Instructions
* @category SetCollection
* @category generated
*/
export type SetCollectionInstructionAccounts = {
candyMachine: web3.PublicKey;
authority: web3.PublicKey;
authorityPda: web3.PublicKey;
payer: web3.PublicKey;
collectionMint: web3.PublicKey;
collectionMetadata: web3.PublicKey;
collectionAuthorityRecord: web3.PublicKey;
newCollectionUpdateAuthority: web3.PublicKey;
newCollectionMetadata: web3.PublicKey;
newCollectionMint: web3.PublicKey;
newCollectionMasterEdition: web3.PublicKey;
newCollectionAuthorityRecord: web3.PublicKey;
tokenMetadataProgram: web3.PublicKey;
systemProgram?: web3.PublicKey;
anchorRemainingAccounts?: web3.AccountMeta[];
};
export const setCollectionInstructionDiscriminator = [192, 254, 206, 76, 168, 182, 59, 223];
/**
* Creates a _SetCollection_ instruction.
*
* @param accounts that will be accessed while the instruction is processed
* @category Instructions
* @category SetCollection
* @category generated
*/
export function createSetCollectionInstruction(
accounts: SetCollectionInstructionAccounts,
programId = new web3.PublicKey('CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR'),
) {
const [data] = setCollectionStruct.serialize({
instructionDiscriminator: setCollectionInstructionDiscriminator,
});
const keys: web3.AccountMeta[] = [
{
pubkey: accounts.candyMachine,
isWritable: true,
isSigner: false,
},
{
pubkey: accounts.authority,
isWritable: false,
isSigner: true,
},
{
pubkey: accounts.authorityPda,
isWritable: true,
isSigner: false,
},
{
pubkey: accounts.payer,
isWritable: false,
isSigner: true,
},
{
pubkey: accounts.collectionMint,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.collectionMetadata,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.collectionAuthorityRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: accounts.newCollectionUpdateAuthority,
isWritable: true,
isSigner: true,
},
{
pubkey: accounts.newCollectionMetadata,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.newCollectionMint,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.newCollectionMasterEdition,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.newCollectionAuthorityRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: accounts.tokenMetadataProgram,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.systemProgram ?? web3.SystemProgram.programId,
isWritable: false,
isSigner: false,
},
];
if (accounts.anchorRemainingAccounts != null) {
for (const acc of accounts.anchorRemainingAccounts) {
keys.push(acc);
}
}
const ix = new web3.TransactionInstruction({
programId,
keys,
data,
});
return ix;
}