@macalinao/clients-quarry
Version:
TypeScript client for Quarry protocol programs
416 lines (408 loc) • 10.6 kB
text/typescript
/**
* 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 type { Address, ReadonlyUint8Array } from "@solana/kit";
import type {
ParsedAcceptAuthorityInstruction,
ParsedClaimRewardsInstruction,
ParsedClaimRewardsV2Instruction,
ParsedCreateMinerInstruction,
ParsedCreateMinerV2Instruction,
ParsedCreateQuarryInstruction,
ParsedCreateQuarryV2Instruction,
ParsedExtractFeesInstruction,
ParsedNewRewarderInstruction,
ParsedNewRewarderV2Instruction,
ParsedPauseInstruction,
ParsedRescueTokensInstruction,
ParsedSetAnnualRewardsInstruction,
ParsedSetFamineInstruction,
ParsedSetPauseAuthorityInstruction,
ParsedSetRewardsShareInstruction,
ParsedStakeTokensInstruction,
ParsedTransferAuthorityInstruction,
ParsedUnpauseInstruction,
ParsedUpdateQuarryRewardsInstruction,
ParsedWithdrawTokensInstruction,
} from "../instructions/index.js";
import { containsBytes, fixEncoderSize, getBytesEncoder } from "@solana/kit";
export const QUARRY_MINE_PROGRAM_ADDRESS =
"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">;
export enum QuarryMineAccount {
Rewarder = 0,
Quarry = 1,
Miner = 2,
}
export function identifyQuarryMineAccount(
account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): QuarryMineAccount {
const data = "data" in account ? account.data : account;
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([83, 3, 203, 174, 244, 30, 172, 198]),
),
0,
)
) {
return QuarryMineAccount.Rewarder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([243, 248, 54, 182, 240, 85, 9, 77]),
),
0,
)
) {
return QuarryMineAccount.Quarry;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([223, 113, 15, 54, 123, 122, 140, 100]),
),
0,
)
) {
return QuarryMineAccount.Miner;
}
throw new Error(
"The provided account could not be identified as a quarryMine account.",
);
}
export enum QuarryMineInstruction {
NewRewarder = 0,
NewRewarderV2 = 1,
SetPauseAuthority = 2,
Pause = 3,
Unpause = 4,
TransferAuthority = 5,
AcceptAuthority = 6,
SetAnnualRewards = 7,
CreateQuarry = 8,
CreateQuarryV2 = 9,
SetRewardsShare = 10,
SetFamine = 11,
UpdateQuarryRewards = 12,
CreateMiner = 13,
CreateMinerV2 = 14,
ClaimRewards = 15,
ClaimRewardsV2 = 16,
StakeTokens = 17,
WithdrawTokens = 18,
RescueTokens = 19,
ExtractFees = 20,
}
export function identifyQuarryMineInstruction(
instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): QuarryMineInstruction {
const data = "data" in instruction ? instruction.data : instruction;
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([1, 115, 16, 244, 109, 74, 67, 209]),
),
0,
)
) {
return QuarryMineInstruction.NewRewarder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([173, 189, 26, 25, 79, 177, 60, 173]),
),
0,
)
) {
return QuarryMineInstruction.NewRewarderV2;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([127, 70, 214, 12, 172, 8, 89, 114]),
),
0,
)
) {
return QuarryMineInstruction.SetPauseAuthority;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]),
),
0,
)
) {
return QuarryMineInstruction.Pause;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]),
),
0,
)
) {
return QuarryMineInstruction.Unpause;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([48, 169, 76, 72, 229, 180, 55, 161]),
),
0,
)
) {
return QuarryMineInstruction.TransferAuthority;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([107, 86, 198, 91, 33, 12, 107, 160]),
),
0,
)
) {
return QuarryMineInstruction.AcceptAuthority;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([135, 125, 92, 160, 100, 101, 141, 84]),
),
0,
)
) {
return QuarryMineInstruction.SetAnnualRewards;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([18, 113, 223, 132, 105, 208, 102, 93]),
),
0,
)
) {
return QuarryMineInstruction.CreateQuarry;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([46, 84, 33, 67, 174, 252, 67, 148]),
),
0,
)
) {
return QuarryMineInstruction.CreateQuarryV2;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([186, 168, 34, 15, 178, 135, 189, 129]),
),
0,
)
) {
return QuarryMineInstruction.SetRewardsShare;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([30, 50, 21, 169, 103, 68, 155, 192]),
),
0,
)
) {
return QuarryMineInstruction.SetFamine;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([42, 213, 243, 249, 125, 145, 44, 242]),
),
0,
)
) {
return QuarryMineInstruction.UpdateQuarryRewards;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([126, 23, 157, 1, 147, 94, 245, 69]),
),
0,
)
) {
return QuarryMineInstruction.CreateMiner;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([177, 242, 29, 176, 13, 217, 36, 71]),
),
0,
)
) {
return QuarryMineInstruction.CreateMinerV2;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([4, 144, 132, 71, 116, 23, 151, 80]),
),
0,
)
) {
return QuarryMineInstruction.ClaimRewards;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([69, 49, 158, 229, 212, 133, 136, 227]),
),
0,
)
) {
return QuarryMineInstruction.ClaimRewardsV2;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([136, 126, 91, 162, 40, 131, 13, 127]),
),
0,
)
) {
return QuarryMineInstruction.StakeTokens;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([2, 4, 225, 61, 19, 182, 106, 170]),
),
0,
)
) {
return QuarryMineInstruction.WithdrawTokens;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([222, 81, 199, 209, 182, 62, 62, 186]),
),
0,
)
) {
return QuarryMineInstruction.RescueTokens;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(
new Uint8Array([57, 219, 44, 55, 130, 127, 165, 183]),
),
0,
)
) {
return QuarryMineInstruction.ExtractFees;
}
throw new Error(
"The provided instruction could not be identified as a quarryMine instruction.",
);
}
export type ParsedQuarryMineInstruction<
TProgram extends string = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB",
> =
| ({
instructionType: QuarryMineInstruction.NewRewarder;
} & ParsedNewRewarderInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.NewRewarderV2;
} & ParsedNewRewarderV2Instruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.SetPauseAuthority;
} & ParsedSetPauseAuthorityInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.Pause;
} & ParsedPauseInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.Unpause;
} & ParsedUnpauseInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.TransferAuthority;
} & ParsedTransferAuthorityInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.AcceptAuthority;
} & ParsedAcceptAuthorityInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.SetAnnualRewards;
} & ParsedSetAnnualRewardsInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.CreateQuarry;
} & ParsedCreateQuarryInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.CreateQuarryV2;
} & ParsedCreateQuarryV2Instruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.SetRewardsShare;
} & ParsedSetRewardsShareInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.SetFamine;
} & ParsedSetFamineInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.UpdateQuarryRewards;
} & ParsedUpdateQuarryRewardsInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.CreateMiner;
} & ParsedCreateMinerInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.CreateMinerV2;
} & ParsedCreateMinerV2Instruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.ClaimRewards;
} & ParsedClaimRewardsInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.ClaimRewardsV2;
} & ParsedClaimRewardsV2Instruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.StakeTokens;
} & ParsedStakeTokensInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.WithdrawTokens;
} & ParsedWithdrawTokensInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.RescueTokens;
} & ParsedRescueTokensInstruction<TProgram>)
| ({
instructionType: QuarryMineInstruction.ExtractFees;
} & ParsedExtractFeesInstruction<TProgram>);