@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
164 lines • 7.21 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.CLOSE_CONTRACT_THREAD_DISCRIMINATOR = void 0;
exports.getCloseContractThreadDiscriminatorBytes = getCloseContractThreadDiscriminatorBytes;
exports.getCloseContractThreadInstructionDataEncoder = getCloseContractThreadInstructionDataEncoder;
exports.getCloseContractThreadInstructionDataDecoder = getCloseContractThreadInstructionDataDecoder;
exports.getCloseContractThreadInstructionDataCodec = getCloseContractThreadInstructionDataCodec;
exports.getCloseContractThreadInstructionAsync = getCloseContractThreadInstructionAsync;
exports.getCloseContractThreadInstruction = getCloseContractThreadInstruction;
exports.parseCloseContractThreadInstruction = parseCloseContractThreadInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.CLOSE_CONTRACT_THREAD_DISCRIMINATOR = new Uint8Array([
213, 35, 77, 150, 62, 109, 103, 248,
]);
function getCloseContractThreadDiscriminatorBytes() {
return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CLOSE_CONTRACT_THREAD_DISCRIMINATOR);
}
function getCloseContractThreadInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)]]), value => ({
...value,
discriminator: exports.CLOSE_CONTRACT_THREAD_DISCRIMINATOR,
}));
}
function getCloseContractThreadInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)]]);
}
function getCloseContractThreadInstructionDataCodec() {
return (0, kit_1.combineCodec)(getCloseContractThreadInstructionDataEncoder(), getCloseContractThreadInstructionDataDecoder());
}
async function getCloseContractThreadInstructionAsync(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
owner: { value: input.owner ?? null, isWritable: true },
contract: { value: input.contract ?? null, isWritable: true },
rentalAuthority: {
value: input.rentalAuthority ?? null,
isWritable: false,
},
thread: { value: input.thread ?? null, isWritable: true },
antegenProgram: { value: input.antegenProgram ?? null, isWritable: false },
fiberProgram: { value: input.fiberProgram ?? null, isWritable: false },
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
};
const accounts = originalAccounts;
// Resolve default values.
if (!accounts.rentalAuthority.value) {
accounts.rentalAuthority.value = await (0, kit_1.getProgramDerivedAddress)({
programAddress,
seeds: [
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([
114, 101, 110, 116, 97, 108, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121,
])),
],
});
}
if (!accounts.antegenProgram.value) {
accounts.antegenProgram.value =
'AgTv5w1UvUb6zeqkThwMrztGu9hpepBu8YLghuR4dpSx';
}
if (!accounts.fiberProgram.value) {
accounts.fiberProgram.value =
'AgFv5afjW9DmSPkiEvJ1er5bAAmRUqaBeTB6Cr8e1hKx';
}
if (!accounts.systemProgram.value) {
accounts.systemProgram.value =
'11111111111111111111111111111111';
}
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta(accounts.owner),
getAccountMeta(accounts.contract),
getAccountMeta(accounts.rentalAuthority),
getAccountMeta(accounts.thread),
getAccountMeta(accounts.antegenProgram),
getAccountMeta(accounts.fiberProgram),
getAccountMeta(accounts.systemProgram),
],
data: getCloseContractThreadInstructionDataEncoder().encode({}),
programAddress,
});
}
function getCloseContractThreadInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
owner: { value: input.owner ?? null, isWritable: true },
contract: { value: input.contract ?? null, isWritable: true },
rentalAuthority: {
value: input.rentalAuthority ?? null,
isWritable: false,
},
thread: { value: input.thread ?? null, isWritable: true },
antegenProgram: { value: input.antegenProgram ?? null, isWritable: false },
fiberProgram: { value: input.fiberProgram ?? null, isWritable: false },
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
};
const accounts = originalAccounts;
// Resolve default values.
if (!accounts.antegenProgram.value) {
accounts.antegenProgram.value =
'AgTv5w1UvUb6zeqkThwMrztGu9hpepBu8YLghuR4dpSx';
}
if (!accounts.fiberProgram.value) {
accounts.fiberProgram.value =
'AgFv5afjW9DmSPkiEvJ1er5bAAmRUqaBeTB6Cr8e1hKx';
}
if (!accounts.systemProgram.value) {
accounts.systemProgram.value =
'11111111111111111111111111111111';
}
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta(accounts.owner),
getAccountMeta(accounts.contract),
getAccountMeta(accounts.rentalAuthority),
getAccountMeta(accounts.thread),
getAccountMeta(accounts.antegenProgram),
getAccountMeta(accounts.fiberProgram),
getAccountMeta(accounts.systemProgram),
],
data: getCloseContractThreadInstructionDataEncoder().encode({}),
programAddress,
});
}
function parseCloseContractThreadInstruction(instruction) {
if (instruction.accounts.length < 7) {
// 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: {
owner: getNextAccount(),
contract: getNextAccount(),
rentalAuthority: getNextAccount(),
thread: getNextAccount(),
antegenProgram: getNextAccount(),
fiberProgram: getNextAccount(),
systemProgram: getNextAccount(),
},
data: getCloseContractThreadInstructionDataDecoder().decode(instruction.data),
};
}
//# sourceMappingURL=closeContractThread.js.map