@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
177 lines • 7.4 kB
JavaScript
/**
* This code was AUTOGENERATED using the Codama library.
* Please DO NOT EDIT THIS FILE, instead use visitors
* to add features, then rerun Codama to update it.
*
* @see https://github.com/codama-idl/codama
*/
import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, transformEncoder, } from '@solana/kit';
import { SRSLY_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory } from '../shared';
export const DELETE_CONFIG_DISCRIMINATOR = new Uint8Array([219, 237, 110, 222, 219, 239, 70, 237]);
export function getDeleteConfigDiscriminatorBytes() {
return fixEncoderSize(getBytesEncoder(), 8).encode(DELETE_CONFIG_DISCRIMINATOR);
}
export function getDeleteConfigInstructionDataEncoder() {
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), value => ({ ...value, discriminator: DELETE_CONFIG_DISCRIMINATOR }));
}
export function getDeleteConfigInstructionDataDecoder() {
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
}
export function getDeleteConfigInstructionDataCodec() {
return combineCodec(getDeleteConfigInstructionDataEncoder(), getDeleteConfigInstructionDataDecoder());
}
export async function getDeleteConfigInstructionAsync(input, config) {
// Program address.
const programAddress = config?.programAddress ?? SRSLY_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
authority: { value: input.authority ?? null, isWritable: true },
config: { value: input.config ?? null, isWritable: true },
mint: { value: input.mint ?? null, isWritable: false },
vault: { value: input.vault ?? null, isWritable: true },
vaultTokenAccount: {
value: input.vaultTokenAccount ?? null,
isWritable: true,
},
srslyProgram: { value: input.srslyProgram ?? null, isWritable: false },
slyvaultProgram: {
value: input.slyvaultProgram ?? null,
isWritable: false,
},
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
};
const accounts = originalAccounts;
// Resolve default values.
if (!accounts.authority.value) {
accounts.authority.value =
'5xoQptcACAAAwPunPAgNgoGfEqywR5VyZdUdzGpaTp2z';
}
if (!accounts.config.value) {
accounts.config.value = await getProgramDerivedAddress({
programAddress,
seeds: [getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103]))],
});
}
if (!accounts.srslyProgram.value) {
accounts.srslyProgram.value =
'SRSLYxcFnjd5jG2DpJw4as6UEyjwJQK1U4J1TD1hvZH';
}
if (!accounts.slyvaultProgram.value) {
accounts.slyvaultProgram.value =
'VLTukwau1TDGhQUgBJfSSojSMv3BfnMHKrewnGN98M3';
}
if (!accounts.tokenProgram.value) {
accounts.tokenProgram.value =
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
}
if (!accounts.systemProgram.value) {
accounts.systemProgram.value =
'11111111111111111111111111111111';
}
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta(accounts.authority),
getAccountMeta(accounts.config),
getAccountMeta(accounts.mint),
getAccountMeta(accounts.vault),
getAccountMeta(accounts.vaultTokenAccount),
getAccountMeta(accounts.srslyProgram),
getAccountMeta(accounts.slyvaultProgram),
getAccountMeta(accounts.tokenProgram),
getAccountMeta(accounts.systemProgram),
],
data: getDeleteConfigInstructionDataEncoder().encode({}),
programAddress,
});
}
export function getDeleteConfigInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? SRSLY_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
authority: { value: input.authority ?? null, isWritable: true },
config: { value: input.config ?? null, isWritable: true },
mint: { value: input.mint ?? null, isWritable: false },
vault: { value: input.vault ?? null, isWritable: true },
vaultTokenAccount: {
value: input.vaultTokenAccount ?? null,
isWritable: true,
},
srslyProgram: { value: input.srslyProgram ?? null, isWritable: false },
slyvaultProgram: {
value: input.slyvaultProgram ?? null,
isWritable: false,
},
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
};
const accounts = originalAccounts;
// Resolve default values.
if (!accounts.authority.value) {
accounts.authority.value =
'5xoQptcACAAAwPunPAgNgoGfEqywR5VyZdUdzGpaTp2z';
}
if (!accounts.srslyProgram.value) {
accounts.srslyProgram.value =
'SRSLYxcFnjd5jG2DpJw4as6UEyjwJQK1U4J1TD1hvZH';
}
if (!accounts.slyvaultProgram.value) {
accounts.slyvaultProgram.value =
'VLTukwau1TDGhQUgBJfSSojSMv3BfnMHKrewnGN98M3';
}
if (!accounts.tokenProgram.value) {
accounts.tokenProgram.value =
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
}
if (!accounts.systemProgram.value) {
accounts.systemProgram.value =
'11111111111111111111111111111111';
}
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta(accounts.authority),
getAccountMeta(accounts.config),
getAccountMeta(accounts.mint),
getAccountMeta(accounts.vault),
getAccountMeta(accounts.vaultTokenAccount),
getAccountMeta(accounts.srslyProgram),
getAccountMeta(accounts.slyvaultProgram),
getAccountMeta(accounts.tokenProgram),
getAccountMeta(accounts.systemProgram),
],
data: getDeleteConfigInstructionDataEncoder().encode({}),
programAddress,
});
}
export function parseDeleteConfigInstruction(instruction) {
if (instruction.accounts.length < 9) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const accountMeta = instruction.accounts[accountIndex];
accountIndex += 1;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: {
authority: getNextAccount(),
config: getNextAccount(),
mint: getNextAccount(),
vault: getNextAccount(),
vaultTokenAccount: getNextAccount(),
srslyProgram: getNextAccount(),
slyvaultProgram: getNextAccount(),
tokenProgram: getNextAccount(),
systemProgram: getNextAccount(),
},
data: getDeleteConfigInstructionDataDecoder().decode(instruction.data),
};
}
//# sourceMappingURL=deleteConfig.js.map