@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
160 lines • 6.71 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_CONTRACT_THREAD_DISCRIMINATOR = new Uint8Array([
113, 179, 247, 242, 60, 125, 240, 68,
]);
export function getDeleteContractThreadDiscriminatorBytes() {
return fixEncoderSize(getBytesEncoder(), 8).encode(DELETE_CONTRACT_THREAD_DISCRIMINATOR);
}
export function getDeleteContractThreadInstructionDataEncoder() {
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), value => ({
...value,
discriminator: DELETE_CONTRACT_THREAD_DISCRIMINATOR,
}));
}
export function getDeleteContractThreadInstructionDataDecoder() {
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
}
export function getDeleteContractThreadInstructionDataCodec() {
return combineCodec(getDeleteContractThreadInstructionDataEncoder(), getDeleteContractThreadInstructionDataDecoder());
}
export async function getDeleteContractThreadInstructionAsync(input, config) {
// Program address.
const programAddress = config?.programAddress ?? SRSLY_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
admin: { value: input.admin ?? null, isWritable: true },
config: { value: input.config ?? null, isWritable: false },
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.config.value) {
accounts.config.value = await getProgramDerivedAddress({
programAddress,
seeds: [getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103]))],
});
}
if (!accounts.rentalAuthority.value) {
accounts.rentalAuthority.value = await getProgramDerivedAddress({
programAddress,
seeds: [
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 = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta(accounts.admin),
getAccountMeta(accounts.config),
getAccountMeta(accounts.rentalAuthority),
getAccountMeta(accounts.thread),
getAccountMeta(accounts.antegenProgram),
getAccountMeta(accounts.fiberProgram),
getAccountMeta(accounts.systemProgram),
],
data: getDeleteContractThreadInstructionDataEncoder().encode({}),
programAddress,
});
}
export function getDeleteContractThreadInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? SRSLY_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
admin: { value: input.admin ?? null, isWritable: true },
config: { value: input.config ?? null, isWritable: false },
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 = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta(accounts.admin),
getAccountMeta(accounts.config),
getAccountMeta(accounts.rentalAuthority),
getAccountMeta(accounts.thread),
getAccountMeta(accounts.antegenProgram),
getAccountMeta(accounts.fiberProgram),
getAccountMeta(accounts.systemProgram),
],
data: getDeleteContractThreadInstructionDataEncoder().encode({}),
programAddress,
});
}
export function parseDeleteContractThreadInstruction(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: {
admin: getNextAccount(),
config: getNextAccount(),
rentalAuthority: getNextAccount(),
thread: getNextAccount(),
antegenProgram: getNextAccount(),
fiberProgram: getNextAccount(),
systemProgram: getNextAccount(),
},
data: getDeleteContractThreadInstructionDataDecoder().decode(instruction.data),
};
}
//# sourceMappingURL=deleteContractThread.js.map