mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-20 11:41:11 +10:00
tsc & prettier
This commit is contained in:
@ -1,72 +1,72 @@
|
||||
import { Filter, FilterResult } from './pool-filters';
|
||||
import { MintLayout } from '@solana/spl-token';
|
||||
import { Connection } from '@solana/web3.js';
|
||||
import { LiquidityPoolKeysV4 } from '@raydium-io/raydium-sdk';
|
||||
import { logger } from '../helpers';
|
||||
import { Filter, FilterResult } from "./pool-filters";
|
||||
import { MintLayout } from "@solana/spl-token";
|
||||
import { Connection } from "@solana/web3.js";
|
||||
import { LiquidityPoolKeysV4 } from "@raydium-io/raydium-sdk";
|
||||
import { logger } from "../helpers";
|
||||
|
||||
export class RenouncedFreezeFilter implements Filter {
|
||||
private readonly errorMessage: string[] = [];
|
||||
private cachedResult: FilterResult | undefined = undefined;
|
||||
private readonly errorMessage: string[] = [];
|
||||
private cachedResult: FilterResult | undefined = undefined;
|
||||
|
||||
constructor(
|
||||
private readonly connection: Connection,
|
||||
private readonly checkRenounced: boolean,
|
||||
private readonly checkFreezable: boolean,
|
||||
) {
|
||||
if (this.checkRenounced) {
|
||||
this.errorMessage.push('mint');
|
||||
}
|
||||
constructor(
|
||||
private readonly connection: Connection,
|
||||
private readonly checkRenounced: boolean,
|
||||
private readonly checkFreezable: boolean,
|
||||
) {
|
||||
if (this.checkRenounced) {
|
||||
this.errorMessage.push("mint");
|
||||
}
|
||||
|
||||
if (this.checkFreezable) {
|
||||
this.errorMessage.push('freeze');
|
||||
}
|
||||
}
|
||||
if (this.checkFreezable) {
|
||||
this.errorMessage.push("freeze");
|
||||
}
|
||||
}
|
||||
|
||||
async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> {
|
||||
if (this.cachedResult) {
|
||||
return this.cachedResult;
|
||||
}
|
||||
async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> {
|
||||
if (this.cachedResult) {
|
||||
return this.cachedResult;
|
||||
}
|
||||
|
||||
try {
|
||||
const accountInfo = await this.connection.getAccountInfo(poolKeys.baseMint, this.connection.commitment);
|
||||
if (!accountInfo?.data) {
|
||||
return { ok: false, message: 'RenouncedFreeze -> Failed to fetch account data' };
|
||||
}
|
||||
try {
|
||||
const accountInfo = await this.connection.getAccountInfo(poolKeys.baseMint, this.connection.commitment);
|
||||
if (!accountInfo?.data) {
|
||||
return { ok: false, message: "RenouncedFreeze -> Failed to fetch account data" };
|
||||
}
|
||||
|
||||
const deserialize = MintLayout.decode(accountInfo.data);
|
||||
const renounced = !this.checkRenounced || deserialize.mintAuthorityOption === 0;
|
||||
const freezable = !this.checkFreezable || deserialize.freezeAuthorityOption !== 0;
|
||||
const ok = renounced && !freezable;
|
||||
const message: string[] = [];
|
||||
const deserialize = MintLayout.decode(accountInfo.data);
|
||||
const renounced = !this.checkRenounced || deserialize.mintAuthorityOption === 0;
|
||||
const freezable = !this.checkFreezable || deserialize.freezeAuthorityOption !== 0;
|
||||
const ok = renounced && !freezable;
|
||||
const message: string[] = [];
|
||||
|
||||
if (!renounced) {
|
||||
message.push('mint');
|
||||
}
|
||||
if (!renounced) {
|
||||
message.push("mint");
|
||||
}
|
||||
|
||||
if (freezable) {
|
||||
message.push('freeze');
|
||||
}
|
||||
if (freezable) {
|
||||
message.push("freeze");
|
||||
}
|
||||
|
||||
const result = {
|
||||
ok: ok,
|
||||
message: ok ? undefined : `RenouncedFreeze -> Creator can ${message.join(' and ')} tokens`,
|
||||
};
|
||||
const result = {
|
||||
ok: ok,
|
||||
message: ok ? undefined : `RenouncedFreeze -> Creator can ${message.join(" and ")} tokens`,
|
||||
};
|
||||
|
||||
if (result.ok) {
|
||||
this.cachedResult = result;
|
||||
}
|
||||
if (result.ok) {
|
||||
this.cachedResult = result;
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
{ mint: poolKeys.baseMint },
|
||||
`RenouncedFreeze -> Failed to check if creator can ${this.errorMessage.join(' and ')} tokens`,
|
||||
);
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
{ mint: poolKeys.baseMint },
|
||||
`RenouncedFreeze -> Failed to check if creator can ${this.errorMessage.join(" and ")} tokens`,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
ok: false,
|
||||
message: `RenouncedFreeze -> Failed to check if creator can ${this.errorMessage.join(' and ')} tokens`,
|
||||
};
|
||||
}
|
||||
return {
|
||||
ok: false,
|
||||
message: `RenouncedFreeze -> Failed to check if creator can ${this.errorMessage.join(" and ")} tokens`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user