@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
187 lines • 8.04 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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DELETE_CONFIG_DISCRIMINATOR = void 0;
exports.getDeleteConfigDiscriminatorBytes = getDeleteConfigDiscriminatorBytes;
exports.getDeleteConfigInstructionDataEncoder = getDeleteConfigInstructionDataEncoder;
exports.getDeleteConfigInstructionDataDecoder = getDeleteConfigInstructionDataDecoder;
exports.getDeleteConfigInstructionDataCodec = getDeleteConfigInstructionDataCodec;
exports.getDeleteConfigInstructionAsync = getDeleteConfigInstructionAsync;
exports.getDeleteConfigInstruction = getDeleteConfigInstruction;
exports.parseDeleteConfigInstruction = parseDeleteConfigInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.DELETE_CONFIG_DISCRIMINATOR = new Uint8Array([219, 237, 110, 222, 219, 239, 70, 237]);
function getDeleteConfigDiscriminatorBytes() {
return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.DELETE_CONFIG_DISCRIMINATOR);
}
function getDeleteConfigInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)]]), value => ({ ...value, discriminator: exports.DELETE_CONFIG_DISCRIMINATOR }));
}
function getDeleteConfigInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)]]);
}
function getDeleteConfigInstructionDataCodec() {
return (0, kit_1.combineCodec)(getDeleteConfigInstructionDataEncoder(), getDeleteConfigInstructionDataDecoder());
}
async function getDeleteConfigInstructionAsync(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.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 (0, kit_1.getProgramDerivedAddress)({
programAddress,
seeds: [(0, kit_1.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 = (0, shared_1.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,
});
}
function getDeleteConfigInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.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 = (0, shared_1.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,
});
}
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