Skip to content

Commit 3d588e8

Browse files
committed
Polish imports, types, tests, and server code
Various tidy-ups and type fixes across the repo: - biome.json: add excludes for coverage and dist to file matcher. - Normalize and reorder imports in multiple modules; export wallet provider classes from wallet index. - Improve TypeScript typings and function signatures (viem Abi/WriteContractParameters, return types, more precise mock/spy types). - Replace unused catch parameters with catch { } and add explicit radix (10) to Number.parseInt calls for correctness. - Adjust tests to use stronger typings for mocks/spies (use never / ReturnType<typeof mock> where appropriate) and reorder test imports for consistency. - Minor server/transport fixes: avoid unused req param, import/registration ordering, and streamable/http transport/import cleanup. - Small fixes in ledger/cosmos modules (import ordering) and other minor refactors to satisfy linters/TypeScript. These changes improve type safety, lint/test reliability, and code consistency.
1 parent d11176b commit 3d588e8

54 files changed

Lines changed: 217 additions & 225 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"includes": ["packages/*/src/**/*.ts", "packages/*/tests/**/*.ts", "**/*.css"]
10+
"includes": ["packages/*/src/**/*.ts", "packages/*/tests/**/*.ts", "**/*.css", "!**/coverage", "!**/dist"]
1111
},
1212
"formatter": {
1313
"enabled": true,

packages/create-sei/src/main.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
1+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
22
import { promises as fs } from "node:fs";
33
import path from "node:path";
44

@@ -11,7 +11,7 @@ describe("Extension System", () => {
1111
// Clean up test directory
1212
try {
1313
await fs.rm(testDir, { recursive: true, force: true });
14-
} catch (e) {
14+
} catch {
1515
// Directory might not exist
1616
}
1717
await fs.mkdir(testDir, { recursive: true });
@@ -21,7 +21,7 @@ describe("Extension System", () => {
2121
// Clean up test directory
2222
try {
2323
await fs.rm(testDir, { recursive: true, force: true });
24-
} catch (e) {
24+
} catch {
2525
// Directory might not exist
2626
}
2727
});

packages/create-sei/src/main.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/usr/bin/env node
2-
import boxen from "boxen";
3-
import inquirer from "inquirer";
42

53
import fs from "node:fs";
6-
import path from "node:path";
7-
import { dirname } from "node:path";
4+
import path, { dirname } from "node:path";
85
import { fileURLToPath } from "node:url";
6+
import boxen from "boxen";
97
import { Command } from "commander";
8+
import inquirer from "inquirer";
109

1110
const __filename = fileURLToPath(import.meta.url);
1211
const __dirname = dirname(__filename);
@@ -87,7 +86,7 @@ async function listExtensions(): Promise<void> {
8786
for (const ext of extensionDirs) {
8887
console.log(` - ${ext}`);
8988
}
90-
} catch (error) {
89+
} catch {
9190
console.log("No extensions directory found.");
9291
}
9392
}
@@ -134,7 +133,7 @@ async function runWizard(options: WizardOptions): Promise<void> {
134133
await fs.promises.access(extensionPath);
135134
await fs.promises.cp(extensionPath, dst, { recursive: true });
136135
console.log(`Applied extension: ${options.extension}`);
137-
} catch (error) {
136+
} catch {
138137
console.log(
139138
`Warning: Extension '${options.extension}' not found. Continuing with base template.`,
140139
);

packages/ledger/src/cosmos/__tests__/seiLedgerOfflineAminoSigner.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, beforeEach, mock } from "bun:test";
1+
import { beforeEach, describe, expect, it, mock } from "bun:test";
22
import { encodeSecp256k1Signature, serializeSignDoc } from "@cosmjs/amino";
33
import { Secp256k1Signature } from "@cosmjs/crypto";
44
import { fromHex } from "@cosmjs/encoding";

packages/ledger/src/cosmos/__tests__/utils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// utils.spec.ts
2-
import { describe, it, expect, beforeEach, mock } from "bun:test";
2+
import { beforeEach, describe, expect, it, mock } from "bun:test";
33
import { createTransportAndApp, getAddresses } from "../utils";
44

55
const mockTransport = {};

packages/ledger/src/cosmos/seiLedgerOfflineAminoSigner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type AminoSignResponse, type OfflineAminoSigner, type StdSignDoc, encodeSecp256k1Signature, serializeSignDoc } from "@cosmjs/amino";
1+
import { type AminoSignResponse, encodeSecp256k1Signature, type OfflineAminoSigner, type StdSignDoc, serializeSignDoc } from "@cosmjs/amino";
22
import { Secp256k1Signature } from "@cosmjs/crypto";
33
import { fromHex } from "@cosmjs/encoding";
44
import type { AccountData } from "@cosmjs/proto-signing";

packages/mcp-server/src/core/chains.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function resolveChainId(chainIdentifier: number | string): number {
5858
}
5959

6060
// Try parsing as a number
61-
const parsedId = Number.parseInt(networkName);
61+
const parsedId = Number.parseInt(networkName, 10);
6262
if (!Number.isNaN(parsedId)) {
6363
return parsedId;
6464
}

packages/mcp-server/src/core/resources.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function registerEVMResources(server: McpServer) {
8787
try {
8888
const network = params.network as string;
8989
const blockNumber = params.blockNumber as string;
90-
const block = await services.getBlockByNumber(Number.parseInt(blockNumber), network);
90+
const block = await services.getBlockByNumber(Number.parseInt(blockNumber, 10), network);
9191

9292
return {
9393
contents: [
@@ -541,7 +541,7 @@ export function registerEVMResources(server: McpServer) {
541541
if (isOwner) {
542542
owner = params.address as string;
543543
}
544-
} catch (e) {
544+
} catch {
545545
// Owner info not available
546546
}
547547

packages/mcp-server/src/core/services/clients.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { http, type Address, type Hex, type PublicClient, type WalletClient, createPublicClient, createWalletClient } from "viem";
2-
import { privateKeyToAccount } from "viem/accounts";
1+
import { type Address, createPublicClient, http, type PublicClient, type WalletClient } from "viem";
32
import { DEFAULT_NETWORK, getChain, getRpcUrl } from "../chains.js";
43
import { getWalletProvider } from "../wallet/index.js";
54

packages/mcp-server/src/core/services/contracts.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { GetLogsParameters, Hash, Hex, Log, ReadContractParameters, WriteContractParameters } from "viem";
1+
import type { Abi, GetLogsParameters, Hash, Hex, Log, ReadContractParameters, WriteContractParameters } from "viem";
22
import { DEFAULT_NETWORK } from "../chains.js";
33
import { getPrivateKeyAsHex } from "../config.js";
44
import { getPublicClient, getWalletClientFromProvider } from "./clients.js";
@@ -19,7 +19,7 @@ export async function readContract(params: ReadContractParameters, network = DEF
1919
* @returns Transaction hash
2020
* @throws Error if no private key is available
2121
*/
22-
export async function writeContract(params: Record<string, any>, network = DEFAULT_NETWORK): Promise<Hash> {
22+
export async function writeContract(params: WriteContractParameters, network = DEFAULT_NETWORK): Promise<Hash> {
2323
// Get private key from environment
2424
const key = getPrivateKeyAsHex();
2525

@@ -28,7 +28,7 @@ export async function writeContract(params: Record<string, any>, network = DEFAU
2828
}
2929

3030
const client = await getWalletClientFromProvider(network);
31-
return await client.writeContract(params as any);
31+
return await client.writeContract(params);
3232
}
3333

3434
/**
@@ -62,7 +62,7 @@ export async function isContract(address: string, network = DEFAULT_NETWORK): Pr
6262
* @returns Object with contract address and transaction hash
6363
* @throws Error if no private key is available or deployment fails
6464
*/
65-
export async function deployContract(bytecode: Hex, abi: any[], args?: any[], network = DEFAULT_NETWORK): Promise<{ address: Hash; transactionHash: Hash }> {
65+
export async function deployContract(bytecode: Hex, abi: Abi, args?: unknown[], network = DEFAULT_NETWORK): Promise<{ address: Hash; transactionHash: Hash }> {
6666
// Get private key from environment
6767
const key = getPrivateKeyAsHex();
6868

0 commit comments

Comments
 (0)