@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
236 lines • 10.3 kB
JavaScript
"use strict";
/**
* 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.CREATE_CONFIG_DISCRIMINATOR = void 0;
exports.getCreateConfigDiscriminatorBytes = getCreateConfigDiscriminatorBytes;
exports.getCreateConfigInstructionDataEncoder = getCreateConfigInstructionDataEncoder;
exports.getCreateConfigInstructionDataDecoder = getCreateConfigInstructionDataDecoder;
exports.getCreateConfigInstructionDataCodec = getCreateConfigInstructionDataCodec;
exports.getCreateConfigInstructionAsync = getCreateConfigInstructionAsync;
exports.getCreateConfigInstruction = getCreateConfigInstruction;
exports.parseCreateConfigInstruction = parseCreateConfigInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.CREATE_CONFIG_DISCRIMINATOR = new Uint8Array([201, 207, 243, 114, 75, 111, 47, 189]);
function getCreateConfigDiscriminatorBytes() {
return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CREATE_CONFIG_DISCRIMINATOR);
}
function getCreateConfigInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
['recentSlot', (0, kit_1.getU64Encoder)()],
]), value => ({ ...value, discriminator: exports.CREATE_CONFIG_DISCRIMINATOR }));
}
function getCreateConfigInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([
['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
['recentSlot', (0, kit_1.getU64Decoder)()],
]);
}
function getCreateConfigInstructionDataCodec() {
return (0, kit_1.combineCodec)(getCreateConfigInstructionDataEncoder(), getCreateConfigInstructionDataDecoder());
}
async function getCreateConfigInstructionAsync(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,
},
lookupTable: { value: input.lookupTable ?? null, isWritable: true },
sageProgram: { value: input.sageProgram ?? null, isWritable: false },
antegenProgram: { value: input.antegenProgram ?? null, isWritable: false },
altProgram: { value: input.altProgram ?? null, isWritable: false },
srslyProgram: { value: input.srslyProgram ?? null, isWritable: false },
slyvaultProgram: {
value: input.slyvaultProgram ?? null,
isWritable: false,
},
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
associatedTokenProgram: {
value: input.associatedTokenProgram ?? null,
isWritable: false,
},
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
};
const accounts = originalAccounts;
// Original args.
const args = { ...input };
// Resolve default values.
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.altProgram.value) {
accounts.altProgram.value =
'AddressLookupTab1e1111111111111111111111111';
}
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.associatedTokenProgram.value) {
accounts.associatedTokenProgram.value =
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
}
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.lookupTable),
getAccountMeta(accounts.sageProgram),
getAccountMeta(accounts.antegenProgram),
getAccountMeta(accounts.altProgram),
getAccountMeta(accounts.srslyProgram),
getAccountMeta(accounts.slyvaultProgram),
getAccountMeta(accounts.tokenProgram),
getAccountMeta(accounts.associatedTokenProgram),
getAccountMeta(accounts.systemProgram),
],
data: getCreateConfigInstructionDataEncoder().encode(args),
programAddress,
});
}
function getCreateConfigInstruction(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,
},
lookupTable: { value: input.lookupTable ?? null, isWritable: true },
sageProgram: { value: input.sageProgram ?? null, isWritable: false },
antegenProgram: { value: input.antegenProgram ?? null, isWritable: false },
altProgram: { value: input.altProgram ?? null, isWritable: false },
srslyProgram: { value: input.srslyProgram ?? null, isWritable: false },
slyvaultProgram: {
value: input.slyvaultProgram ?? null,
isWritable: false,
},
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
associatedTokenProgram: {
value: input.associatedTokenProgram ?? null,
isWritable: false,
},
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
};
const accounts = originalAccounts;
// Original args.
const args = { ...input };
// Resolve default values.
if (!accounts.altProgram.value) {
accounts.altProgram.value =
'AddressLookupTab1e1111111111111111111111111';
}
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.associatedTokenProgram.value) {
accounts.associatedTokenProgram.value =
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
}
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.lookupTable),
getAccountMeta(accounts.sageProgram),
getAccountMeta(accounts.antegenProgram),
getAccountMeta(accounts.altProgram),
getAccountMeta(accounts.srslyProgram),
getAccountMeta(accounts.slyvaultProgram),
getAccountMeta(accounts.tokenProgram),
getAccountMeta(accounts.associatedTokenProgram),
getAccountMeta(accounts.systemProgram),
],
data: getCreateConfigInstructionDataEncoder().encode(args),
programAddress,
});
}
function parseCreateConfigInstruction(instruction) {
if (instruction.accounts.length < 14) {
// 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(),
lookupTable: getNextAccount(),
sageProgram: getNextAccount(),
antegenProgram: getNextAccount(),
altProgram: getNextAccount(),
srslyProgram: getNextAccount(),
slyvaultProgram: getNextAccount(),
tokenProgram: getNextAccount(),
associatedTokenProgram: getNextAccount(),
systemProgram: getNextAccount(),
},
data: getCreateConfigInstructionDataDecoder().decode(instruction.data),
};
}
//# sourceMappingURL=createConfig.js.map