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

@ -226,7 +226,6 @@
"integrity": "sha512-5FcvN1JHw2sHJChotgx8Ek0lyuh4kCKelgMTTqhYJJtloNvUfpAFMeNQUtdlIaktwrSV9LtCdqwk48wL2wBacQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.24.2",
@ -2743,7 +2742,6 @@
"integrity": "sha512-F1CBxgqwOMc4GKJ7eY22hWhBVQuMYTtqI8L0FcszYcpYX0fzfDGpez22Xau8Mgm7O9fI+zA/TYIdq3tGWfweBA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"undici-types": "~7.13.0"
}
@ -2804,7 +2802,6 @@
"integrity": "sha512-TGf22kon8KW+DeKaUmOibKWktRY8b2NSAZNdtWh798COm1NWx8+xJ6iFBtk3IvLdv6+LGLJLRlyhrhEDZWargQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "8.45.0",
"@typescript-eslint/types": "8.45.0",
@ -3416,7 +3413,6 @@
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@ -3741,7 +3737,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"caniuse-lite": "^1.0.30001587",
"electron-to-chromium": "^1.4.668",
@ -4530,7 +4525,6 @@
"integrity": "sha512-hB4FIzXovouYzwzECDcUkJ4OcfOEkXTv2zRY6B9bkwjx/cprAq0uvm1nl7zvQ0/TsUk0zQiN4uPfJpB9m+rPMQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.1",
@ -5228,7 +5222,6 @@
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz",
"integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==",
"license": "MIT",
"peer": true,
"engines": {
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
}
@ -5311,9 +5304,8 @@
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.16.0.tgz",
"integrity": "sha512-Ju2RCU2dQMgSKtArPbEtsK5gNLnsQyTNIo/T7cZNp96niC1x0KdJNZV0TIoilceBPQwfb5itrGl8pkFeOUMl4A==",
"devOptional": true,
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=10"
},
@ -7220,7 +7212,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@ -8155,9 +8146,8 @@
"version": "5.4.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz",
"integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==",
"devOptional": true,
"dev": true,
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@ -8364,7 +8354,6 @@
"integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"esbuild": "^0.27.0",
"fdir": "^6.5.0",
@ -8463,7 +8452,6 @@
"integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@types/chai": "^5.2.2",
"@vitest/expect": "3.2.4",
@ -8679,7 +8667,6 @@
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=10.0.0"
},

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;
}