|
@@ -4,23 +4,28 @@ import { Connection } from '@solana/web3.js';
|
|
|
import { LiquidityPoolKeysV4 } from '@raydium-io/raydium-sdk';
|
|
|
import { logger } from '../helpers';
|
|
|
|
|
|
-export class RenouncedFilter implements Filter {
|
|
|
- constructor(private readonly connection: Connection) {}
|
|
|
+export class RenouncedFreezeFilter implements Filter {
|
|
|
+ constructor(private readonly connection: Connection, private readonly checkRenounced: boolean, private readonly checkFreezable: boolean) {}
|
|
|
|
|
|
async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> {
|
|
|
try {
|
|
|
const accountInfo = await this.connection.getAccountInfo(poolKeys.baseMint, this.connection.commitment);
|
|
|
if (!accountInfo?.data) {
|
|
|
- return { ok: false, message: 'Renounced -> Failed to fetch account data' };
|
|
|
+ return { ok: false, message: 'Failed to fetch account data' };
|
|
|
}
|
|
|
|
|
|
const deserialize = MintLayout.decode(accountInfo.data);
|
|
|
- const renounced = deserialize.mintAuthorityOption === 0;
|
|
|
- return { ok: renounced, message: renounced ? undefined : 'Renounced -> Creator can mint more tokens' };
|
|
|
+ const renounced = !this.checkRenounced || deserialize.mintAuthorityOption === 0;
|
|
|
+ const freezable = !this.checkFreezable || deserialize.freezeAuthorityOption !== 0;
|
|
|
+
|
|
|
+ const message = [ renounced ? undefined : 'mint', !freezable ? undefined : 'freeze' ].filter((e) => e !== undefined);
|
|
|
+ const ok = renounced && !freezable;
|
|
|
+
|
|
|
+ return { ok: ok, message: ok ? undefined : `RenouncedFreeze -> Creator can ${message.join(' and ')} tokens` };
|
|
|
} catch (e) {
|
|
|
- logger.error({ mint: poolKeys.baseMint }, `Failed to check if mint is renounced`);
|
|
|
+ logger.error({ mint: poolKeys.baseMint }, `Failed to check if mint is renounced and freezable`);
|
|
|
}
|
|
|
|
|
|
- return { ok: false, message: 'Renounced -> Failed to check if mint is renounced' };
|
|
|
+ return { ok: false, message: 'Renounced -> Failed to check if mint is renounced and freezable' };
|
|
|
}
|
|
|
}
|