/
DecreaseStorage2.go
355 lines (314 loc) · 12.2 KB
/
DecreaseStorage2.go
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT.
package shadow_drive_user_staking
import (
"errors"
ag_binary "github.com/gagliardetto/binary"
ag_solanago "github.com/gagliardetto/solana-go"
ag_format "github.com/gagliardetto/solana-go/text/format"
ag_treeout "github.com/gagliardetto/treeout"
)
// DecreaseStorage2 is the `decreaseStorage2` instruction.
type DecreaseStorage2 struct {
RemoveStorage *uint64
// [0] = [WRITE] storageConfig
//
// [1] = [WRITE] storageAccount
//
// [2] = [WRITE] unstakeInfo
//
// [3] = [WRITE] unstakeAccount
//
// [4] = [WRITE, SIGNER] owner
//
// [5] = [WRITE] ownerAta
//
// [6] = [WRITE] stakeAccount
//
// [7] = [] tokenMint
//
// [8] = [SIGNER] uploader
//
// [9] = [WRITE] emissionsWallet
//
// [10] = [] systemProgram
//
// [11] = [] tokenProgram
//
// [12] = [] rent
ag_solanago.AccountMetaSlice `bin:"-"`
}
// NewDecreaseStorage2InstructionBuilder creates a new `DecreaseStorage2` instruction builder.
func NewDecreaseStorage2InstructionBuilder() *DecreaseStorage2 {
nd := &DecreaseStorage2{
AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 13),
}
return nd
}
// SetRemoveStorage sets the "removeStorage" parameter.
func (inst *DecreaseStorage2) SetRemoveStorage(removeStorage uint64) *DecreaseStorage2 {
inst.RemoveStorage = &removeStorage
return inst
}
// SetStorageConfigAccount sets the "storageConfig" account.
func (inst *DecreaseStorage2) SetStorageConfigAccount(storageConfig ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[0] = ag_solanago.Meta(storageConfig).WRITE()
return inst
}
// GetStorageConfigAccount gets the "storageConfig" account.
func (inst *DecreaseStorage2) GetStorageConfigAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(0)
}
// SetStorageAccountAccount sets the "storageAccount" account.
func (inst *DecreaseStorage2) SetStorageAccountAccount(storageAccount ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[1] = ag_solanago.Meta(storageAccount).WRITE()
return inst
}
// GetStorageAccountAccount gets the "storageAccount" account.
func (inst *DecreaseStorage2) GetStorageAccountAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(1)
}
// SetUnstakeInfoAccount sets the "unstakeInfo" account.
func (inst *DecreaseStorage2) SetUnstakeInfoAccount(unstakeInfo ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[2] = ag_solanago.Meta(unstakeInfo).WRITE()
return inst
}
// GetUnstakeInfoAccount gets the "unstakeInfo" account.
func (inst *DecreaseStorage2) GetUnstakeInfoAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(2)
}
// SetUnstakeAccountAccount sets the "unstakeAccount" account.
func (inst *DecreaseStorage2) SetUnstakeAccountAccount(unstakeAccount ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[3] = ag_solanago.Meta(unstakeAccount).WRITE()
return inst
}
// GetUnstakeAccountAccount gets the "unstakeAccount" account.
func (inst *DecreaseStorage2) GetUnstakeAccountAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(3)
}
// SetOwnerAccount sets the "owner" account.
func (inst *DecreaseStorage2) SetOwnerAccount(owner ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[4] = ag_solanago.Meta(owner).WRITE().SIGNER()
return inst
}
// GetOwnerAccount gets the "owner" account.
func (inst *DecreaseStorage2) GetOwnerAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(4)
}
// SetOwnerAtaAccount sets the "ownerAta" account.
func (inst *DecreaseStorage2) SetOwnerAtaAccount(ownerAta ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[5] = ag_solanago.Meta(ownerAta).WRITE()
return inst
}
// GetOwnerAtaAccount gets the "ownerAta" account.
func (inst *DecreaseStorage2) GetOwnerAtaAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(5)
}
// SetStakeAccountAccount sets the "stakeAccount" account.
func (inst *DecreaseStorage2) SetStakeAccountAccount(stakeAccount ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[6] = ag_solanago.Meta(stakeAccount).WRITE()
return inst
}
// GetStakeAccountAccount gets the "stakeAccount" account.
func (inst *DecreaseStorage2) GetStakeAccountAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(6)
}
// SetTokenMintAccount sets the "tokenMint" account.
func (inst *DecreaseStorage2) SetTokenMintAccount(tokenMint ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenMint)
return inst
}
// GetTokenMintAccount gets the "tokenMint" account.
func (inst *DecreaseStorage2) GetTokenMintAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(7)
}
// SetUploaderAccount sets the "uploader" account.
func (inst *DecreaseStorage2) SetUploaderAccount(uploader ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[8] = ag_solanago.Meta(uploader).SIGNER()
return inst
}
// GetUploaderAccount gets the "uploader" account.
func (inst *DecreaseStorage2) GetUploaderAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(8)
}
// SetEmissionsWalletAccount sets the "emissionsWallet" account.
func (inst *DecreaseStorage2) SetEmissionsWalletAccount(emissionsWallet ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[9] = ag_solanago.Meta(emissionsWallet).WRITE()
return inst
}
// GetEmissionsWalletAccount gets the "emissionsWallet" account.
func (inst *DecreaseStorage2) GetEmissionsWalletAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(9)
}
// SetSystemProgramAccount sets the "systemProgram" account.
func (inst *DecreaseStorage2) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[10] = ag_solanago.Meta(systemProgram)
return inst
}
// GetSystemProgramAccount gets the "systemProgram" account.
func (inst *DecreaseStorage2) GetSystemProgramAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(10)
}
// SetTokenProgramAccount sets the "tokenProgram" account.
func (inst *DecreaseStorage2) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[11] = ag_solanago.Meta(tokenProgram)
return inst
}
// GetTokenProgramAccount gets the "tokenProgram" account.
func (inst *DecreaseStorage2) GetTokenProgramAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(11)
}
// SetRentAccount sets the "rent" account.
func (inst *DecreaseStorage2) SetRentAccount(rent ag_solanago.PublicKey) *DecreaseStorage2 {
inst.AccountMetaSlice[12] = ag_solanago.Meta(rent)
return inst
}
// GetRentAccount gets the "rent" account.
func (inst *DecreaseStorage2) GetRentAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(12)
}
func (inst DecreaseStorage2) Build() *Instruction {
return &Instruction{BaseVariant: ag_binary.BaseVariant{
Impl: inst,
TypeID: Instruction_DecreaseStorage2,
}}
}
// ValidateAndBuild validates the instruction parameters and accounts;
// if there is a validation error, it returns the error.
// Otherwise, it builds and returns the instruction.
func (inst DecreaseStorage2) ValidateAndBuild() (*Instruction, error) {
if err := inst.Validate(); err != nil {
return nil, err
}
return inst.Build(), nil
}
func (inst *DecreaseStorage2) Validate() error {
// Check whether all (required) parameters are set:
{
if inst.RemoveStorage == nil {
return errors.New("RemoveStorage parameter is not set")
}
}
// Check whether all (required) accounts are set:
{
if inst.AccountMetaSlice[0] == nil {
return errors.New("accounts.StorageConfig is not set")
}
if inst.AccountMetaSlice[1] == nil {
return errors.New("accounts.StorageAccount is not set")
}
if inst.AccountMetaSlice[2] == nil {
return errors.New("accounts.UnstakeInfo is not set")
}
if inst.AccountMetaSlice[3] == nil {
return errors.New("accounts.UnstakeAccount is not set")
}
if inst.AccountMetaSlice[4] == nil {
return errors.New("accounts.Owner is not set")
}
if inst.AccountMetaSlice[5] == nil {
return errors.New("accounts.OwnerAta is not set")
}
if inst.AccountMetaSlice[6] == nil {
return errors.New("accounts.StakeAccount is not set")
}
if inst.AccountMetaSlice[7] == nil {
return errors.New("accounts.TokenMint is not set")
}
if inst.AccountMetaSlice[8] == nil {
return errors.New("accounts.Uploader is not set")
}
if inst.AccountMetaSlice[9] == nil {
return errors.New("accounts.EmissionsWallet is not set")
}
if inst.AccountMetaSlice[10] == nil {
return errors.New("accounts.SystemProgram is not set")
}
if inst.AccountMetaSlice[11] == nil {
return errors.New("accounts.TokenProgram is not set")
}
if inst.AccountMetaSlice[12] == nil {
return errors.New("accounts.Rent is not set")
}
}
return nil
}
func (inst *DecreaseStorage2) EncodeToTree(parent ag_treeout.Branches) {
parent.Child(ag_format.Program(ProgramName, ProgramID)).
//
ParentFunc(func(programBranch ag_treeout.Branches) {
programBranch.Child(ag_format.Instruction("DecreaseStorage2")).
//
ParentFunc(func(instructionBranch ag_treeout.Branches) {
// Parameters of the instruction:
instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) {
paramsBranch.Child(ag_format.Param("RemoveStorage", *inst.RemoveStorage))
})
// Accounts of the instruction:
instructionBranch.Child("Accounts[len=13]").ParentFunc(func(accountsBranch ag_treeout.Branches) {
accountsBranch.Child(ag_format.Meta(" storageConfig", inst.AccountMetaSlice.Get(0)))
accountsBranch.Child(ag_format.Meta(" storage", inst.AccountMetaSlice.Get(1)))
accountsBranch.Child(ag_format.Meta(" unstakeInfo", inst.AccountMetaSlice.Get(2)))
accountsBranch.Child(ag_format.Meta(" unstake", inst.AccountMetaSlice.Get(3)))
accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(4)))
accountsBranch.Child(ag_format.Meta(" ownerAta", inst.AccountMetaSlice.Get(5)))
accountsBranch.Child(ag_format.Meta(" stake", inst.AccountMetaSlice.Get(6)))
accountsBranch.Child(ag_format.Meta(" tokenMint", inst.AccountMetaSlice.Get(7)))
accountsBranch.Child(ag_format.Meta(" uploader", inst.AccountMetaSlice.Get(8)))
accountsBranch.Child(ag_format.Meta("emissionsWallet", inst.AccountMetaSlice.Get(9)))
accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(10)))
accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(11)))
accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(12)))
})
})
})
}
func (obj DecreaseStorage2) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
// Serialize `RemoveStorage` param:
err = encoder.Encode(obj.RemoveStorage)
if err != nil {
return err
}
return nil
}
func (obj *DecreaseStorage2) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
// Deserialize `RemoveStorage`:
err = decoder.Decode(&obj.RemoveStorage)
if err != nil {
return err
}
return nil
}
// NewDecreaseStorage2Instruction declares a new DecreaseStorage2 instruction with the provided parameters and accounts.
func NewDecreaseStorage2Instruction(
// Parameters:
removeStorage uint64,
// Accounts:
storageConfig ag_solanago.PublicKey,
storageAccount ag_solanago.PublicKey,
unstakeInfo ag_solanago.PublicKey,
unstakeAccount ag_solanago.PublicKey,
owner ag_solanago.PublicKey,
ownerAta ag_solanago.PublicKey,
stakeAccount ag_solanago.PublicKey,
tokenMint ag_solanago.PublicKey,
uploader ag_solanago.PublicKey,
emissionsWallet ag_solanago.PublicKey,
systemProgram ag_solanago.PublicKey,
tokenProgram ag_solanago.PublicKey,
rent ag_solanago.PublicKey) *DecreaseStorage2 {
return NewDecreaseStorage2InstructionBuilder().
SetRemoveStorage(removeStorage).
SetStorageConfigAccount(storageConfig).
SetStorageAccountAccount(storageAccount).
SetUnstakeInfoAccount(unstakeInfo).
SetUnstakeAccountAccount(unstakeAccount).
SetOwnerAccount(owner).
SetOwnerAtaAccount(ownerAta).
SetStakeAccountAccount(stakeAccount).
SetTokenMintAccount(tokenMint).
SetUploaderAccount(uploader).
SetEmissionsWalletAccount(emissionsWallet).
SetSystemProgramAccount(systemProgram).
SetTokenProgramAccount(tokenProgram).
SetRentAccount(rent)
}