fix: address review findings from recenterAccess cleanup (#887)

- Remove permanently unreachable guard branches from evaluateRecenterOpportunity
- Remove orphaned getWalletAddress() from BlockchainService
- Simplify RecenterAccessStatus type: drop always-null recenterAccessAddress
  and slot fields, narrow hasAccess to boolean
- Update /status endpoint to match simplified type
- Remove test script (no test files remain)
- Revert unrelated kraiken-lib/package-lock.json churn

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-17 13:22:10 +00:00
parent f2ba1181f4
commit ad680b8ced
5 changed files with 4 additions and 50 deletions

View file

@ -8,7 +8,6 @@
"build": "tsc -p tsconfig.build.json",
"start": "node dist/service.js",
"dev": "tsx watch src/service.ts",
"test": "node --test --import tsx",
"lint": "eslint src/**/*.ts",
"lint:fix": "eslint --fix src/**/*.ts",
"format": "prettier --write src/**/*.ts",

View file

@ -121,8 +121,6 @@ export function createTxnBot(dependencies: TxnBotDependencies): TxnBotInstance {
lastRecenterAccessStatus = {
hasAccess: true,
recenterAccessAddress: null,
slot: null,
checkedAtMs: now,
error: null,
};
@ -132,28 +130,6 @@ export function createTxnBot(dependencies: TxnBotDependencies): TxnBotInstance {
async function evaluateRecenterOpportunity(): Promise<RecenterEligibility> {
const now = Date.now();
const accessStatus = await getRecenterAccessStatus(true);
if (accessStatus.error && accessStatus.hasAccess === null) {
lastRecenterEligibility = {
checkedAtMs: now,
canRecenter: false,
reason: 'Failed to determine recenter access.',
error: accessStatus.error,
};
return lastRecenterEligibility;
}
if (accessStatus.hasAccess === false) {
lastRecenterEligibility = {
checkedAtMs: now,
canRecenter: false,
reason: 'txnBot is not the authorized recenter caller.',
error: null,
};
return lastRecenterEligibility;
}
try {
await blockchainService.estimateRecenterGas();
lastRecenterEligibility = {
@ -265,9 +241,7 @@ export function createTxnBot(dependencies: TxnBotDependencies): TxnBotInstance {
lastLiquidationTime: lastLiquidationTime ? lastLiquidationTime.toISOString() : 'Never',
lastRecenterTx,
recenterAccess: {
hasAccess: recenterAccessStatus?.hasAccess ?? null,
grantedTo: recenterAccessStatus?.recenterAccessAddress ?? null,
slot: recenterAccessStatus?.slot ?? null,
hasAccess: recenterAccessStatus?.hasAccess ?? true,
checkedAt: recenterAccessStatus?.checkedAtMs ? new Date(recenterAccessStatus.checkedAtMs).toISOString() : null,
error: recenterAccessStatus?.error ?? null,
},

View file

@ -35,10 +35,6 @@ export class BlockchainService {
this.stakeContract = new ethers.Contract(config.stakeContractAddress, STAKE_ABI, this.wallet);
}
getWalletAddress(): string {
return ethers.getAddress(this.wallet.address);
}
async checkFunds(): Promise<string> {
const balance = await this.provider.getBalance(this.wallet.address);
return ethers.formatEther(balance);

View file

@ -17,9 +17,7 @@ export interface EnvConfig {
}
export interface RecenterAccessStatus {
hasAccess: boolean | null;
recenterAccessAddress: string | null;
slot: string | null;
hasAccess: boolean;
checkedAtMs: number;
error: string | null;
}