gov-ix: create an idl-resize instruction (#752)

This commit is contained in:
Christian Kamm 2023-10-11 15:22:06 +02:00 committed by GitHub
parent c354f55423
commit 5809281f24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import {
PublicKey,
SYSVAR_RENT_PUBKEY,
SystemProgram,
TransactionInstruction,
} from '@solana/web3.js';
import fs from 'fs';
import { TokenIndex } from '../src/accounts/bank';
@ -381,15 +382,46 @@ async function createMangoAccount(): Promise<void> {
console.log(await serializeInstructionToBase64(ix));
}
async function idlResize(): Promise<void> {
// anchor constant for all idl-specific instructions
const idlIxBytes = [0x40, 0xf4, 0xbc, 0x78, 0xa7, 0xe9, 0x69, 0x0a];
const idlIxNum = 6; // resize
const newSize = new BN(19000);
const ix = new TransactionInstruction({
keys: [
{
pubkey: new PublicKey('3foqXduY5PabCn6LjNrLo3waNf3Hy6vQgqavoVUCsUN9'), // idl account
isSigner: false,
isWritable: true,
},
{
pubkey: new PublicKey('FP4PxqHTVzeG2c6eZd7974F9WvKUSdBeduUK3rjYyvBw'), // authority
isSigner: true,
isWritable: true,
},
{
pubkey: new PublicKey('11111111111111111111111111111111'), // system program
isSigner: false,
isWritable: false,
},
],
programId: MANGO_V4_ID['mainnet-beta'],
data: Buffer.from(idlIxBytes.concat([idlIxNum], newSize.toArray('le', 8))),
});
console.log(await serializeInstructionToBase64(ix));
}
async function main(): Promise<void> {
try {
// await tokenRegister();
// await tokenEdit();
// await perpCreate();
await perpEdit();
// await perpEdit();
// await serum3Register();
// await ixDisable();
// await createMangoAccount();
await idlResize();
} catch (error) {
console.log(error);
}